From cdb7d153dcf05a614df5621ff738149eebcca16b Mon Sep 17 00:00:00 2001 From: Mike Tsao Date: Wed, 21 Feb 2024 07:20:14 -0800 Subject: [PATCH] `ui.dnd_drop_zone()` now returns `InnerResponse`. (#4079) * Closes ```bash $ ./scripts/check.sh [...] + echo 'All checks passed.' ``` --- crates/egui/src/ui.rs | 10 +++++----- crates/egui_demo_lib/src/demo/drag_and_drop.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/egui/src/ui.rs b/crates/egui/src/ui.rs index b5f861897c7b..b821601195be 100644 --- a/crates/egui/src/ui.rs +++ b/crates/egui/src/ui.rs @@ -2223,11 +2223,11 @@ impl Ui { /// /// The given frame is used for its margins, but it color is ignored. #[doc(alias = "drag and drop")] - pub fn dnd_drop_zone( + pub fn dnd_drop_zone( &mut self, frame: Frame, - add_contents: impl FnOnce(&mut Ui), - ) -> (Response, Option>) + add_contents: impl FnOnce(&mut Ui) -> R, + ) -> (InnerResponse, Option>) where Payload: Any + Send + Sync, { @@ -2236,7 +2236,7 @@ impl Ui { DragAndDrop::has_payload_of_type::(self.ctx()); let mut frame = frame.begin(self); - add_contents(&mut frame.content_ui); + let inner = add_contents(&mut frame.content_ui); let response = frame.allocate_space(self); // NOTE: we use `response.contains_pointer` here instead of `hovered`, because @@ -2266,7 +2266,7 @@ impl Ui { let payload = response.dnd_release_payload::(); - (response, payload) + (InnerResponse { inner, response }, payload) } /// Close the menu we are in (including submenus), if any. diff --git a/crates/egui_demo_lib/src/demo/drag_and_drop.rs b/crates/egui_demo_lib/src/demo/drag_and_drop.rs index 29bda3350ac9..883095953ff4 100644 --- a/crates/egui_demo_lib/src/demo/drag_and_drop.rs +++ b/crates/egui_demo_lib/src/demo/drag_and_drop.rs @@ -60,7 +60,7 @@ impl super::View for DragAndDropDemo { let frame = Frame::default().inner_margin(4.0); - let (_, dropped_payload) = ui.dnd_drop_zone::(frame, |ui| { + let (_, dropped_payload) = ui.dnd_drop_zone::(frame, |ui| { ui.set_min_size(vec2(64.0, 100.0)); for (row_idx, item) in column.iter().enumerate() { let item_id = Id::new(("my_drag_and_drop_demo", col_idx, row_idx));