From 7017947b7ea6a3fea99f76a855f550dea0677abe Mon Sep 17 00:00:00 2001 From: Aufar Zakiev Date: Fri, 26 Jan 2024 22:38:22 +0300 Subject: [PATCH 1/3] Fix: `context menu` requires now a reference to self --- crates/egui/src/response.rs | 3 +-- crates/egui_demo_lib/src/demo/drag_and_drop.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/egui/src/response.rs b/crates/egui/src/response.rs index 178c28a6798..d93cf510088 100644 --- a/crates/egui/src/response.rs +++ b/crates/egui/src/response.rs @@ -718,9 +718,8 @@ impl Response { /// ``` /// /// See also: [`Ui::menu_button`] and [`Ui::close_menu`]. - pub fn context_menu(self, add_contents: impl FnOnce(&mut Ui)) -> Self { + pub fn context_menu(&self, add_contents: impl FnOnce(&mut Ui)) { menu::context_menu(&self, add_contents); - self } } 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 37c21238047..3c27735ca37 100644 --- a/crates/egui_demo_lib/src/demo/drag_and_drop.rs +++ b/crates/egui_demo_lib/src/demo/drag_and_drop.rs @@ -144,7 +144,7 @@ impl super::View for DragAndDropDemo { }) .response; - let response = response.context_menu(|ui| { + response.context_menu(|ui| { if ui.button("New Item").clicked() { self.columns[col_idx].push("New Item".to_owned()); ui.close_menu(); From cf843094fe606706cb0abbfb395ea12103725f73 Mon Sep 17 00:00:00 2001 From: Aufar Zakiev Date: Sat, 27 Jan 2024 15:50:51 +0300 Subject: [PATCH 2/3] Better fix --- crates/egui/src/response.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/egui/src/response.rs b/crates/egui/src/response.rs index d93cf510088..a689fbb4d7d 100644 --- a/crates/egui/src/response.rs +++ b/crates/egui/src/response.rs @@ -718,8 +718,8 @@ impl Response { /// ``` /// /// See also: [`Ui::menu_button`] and [`Ui::close_menu`]. - pub fn context_menu(&self, add_contents: impl FnOnce(&mut Ui)) { - menu::context_menu(&self, add_contents); + pub fn context_menu(&self, add_contents: impl FnOnce(&mut Ui)) -> Option> { + menu::context_menu(&self, add_contents) } } From 5da3e8858756ae15ae76213b01fd27554adcc668 Mon Sep 17 00:00:00 2001 From: Aufar Zakiev Date: Sat, 27 Jan 2024 17:11:14 +0300 Subject: [PATCH 3/3] Even better fix --- crates/egui/src/response.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/egui/src/response.rs b/crates/egui/src/response.rs index a689fbb4d7d..885857809c7 100644 --- a/crates/egui/src/response.rs +++ b/crates/egui/src/response.rs @@ -719,7 +719,7 @@ impl Response { /// /// See also: [`Ui::menu_button`] and [`Ui::close_menu`]. pub fn context_menu(&self, add_contents: impl FnOnce(&mut Ui)) -> Option> { - menu::context_menu(&self, add_contents) + menu::context_menu(self, add_contents) } }