Skip to content

Commit 4305800

Browse files
sowbughacknus
authored andcommitted
ui.dnd_drop_zone() now returns InnerResponse. (emilk#4079)
* Closes <emilk#4059> ```bash $ ./scripts/check.sh [...] + echo 'All checks passed.' ```
1 parent 3e1f2f9 commit 4305800

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

crates/egui/src/ui.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2223,11 +2223,11 @@ impl Ui {
22232223
///
22242224
/// The given frame is used for its margins, but it color is ignored.
22252225
#[doc(alias = "drag and drop")]
2226-
pub fn dnd_drop_zone<Payload>(
2226+
pub fn dnd_drop_zone<Payload, R>(
22272227
&mut self,
22282228
frame: Frame,
2229-
add_contents: impl FnOnce(&mut Ui),
2230-
) -> (Response, Option<Arc<Payload>>)
2229+
add_contents: impl FnOnce(&mut Ui) -> R,
2230+
) -> (InnerResponse<R>, Option<Arc<Payload>>)
22312231
where
22322232
Payload: Any + Send + Sync,
22332233
{
@@ -2236,7 +2236,7 @@ impl Ui {
22362236
DragAndDrop::has_payload_of_type::<Payload>(self.ctx());
22372237

22382238
let mut frame = frame.begin(self);
2239-
add_contents(&mut frame.content_ui);
2239+
let inner = add_contents(&mut frame.content_ui);
22402240
let response = frame.allocate_space(self);
22412241

22422242
// NOTE: we use `response.contains_pointer` here instead of `hovered`, because
@@ -2266,7 +2266,7 @@ impl Ui {
22662266

22672267
let payload = response.dnd_release_payload::<Payload>();
22682268

2269-
(response, payload)
2269+
(InnerResponse { inner, response }, payload)
22702270
}
22712271

22722272
/// Close the menu we are in (including submenus), if any.

crates/egui_demo_lib/src/demo/drag_and_drop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl super::View for DragAndDropDemo {
6060

6161
let frame = Frame::default().inner_margin(4.0);
6262

63-
let (_, dropped_payload) = ui.dnd_drop_zone::<Location>(frame, |ui| {
63+
let (_, dropped_payload) = ui.dnd_drop_zone::<Location, ()>(frame, |ui| {
6464
ui.set_min_size(vec2(64.0, 100.0));
6565
for (row_idx, item) in column.iter().enumerate() {
6666
let item_id = Id::new(("my_drag_and_drop_demo", col_idx, row_idx));

0 commit comments

Comments
 (0)