Skip to content

Commit cbfc743

Browse files
committed
Define useful Response for SubMenu::show
an InnerResponse for the SubMenu button Response with an optional inner Response for the extended SubMenu
1 parent 1c89099 commit cbfc743

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

egui/src/context_menu.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use super::{
44
WidgetVisuals,
55
}, CtxRef, Align, Id, PointerState, Pos2, Rect, Response, Sense,
66
Style, TextStyle, Ui, Vec2,
7+
InnerResponse,
78
};
89

910
#[derive(Default)]
@@ -240,13 +241,14 @@ impl<'a> SubMenu<'a> {
240241
parent_state,
241242
}
242243
}
243-
pub fn show(self, ui: &mut Ui, add_contents: impl FnOnce(&mut Ui, &mut MenuState)) {
244+
pub fn show(self, ui: &mut Ui, add_contents: impl FnOnce(&mut Ui, &mut MenuState)) -> InnerResponse<Option<Response>> {
244245
let sub_id = ui.id().with(self.entry.index);
245246
let button = self.entry.show_with_state(ui, EntryState::submenu(self.parent_state, sub_id));
246247
self.parent_state
247248
.submenu_button_interaction(ui, sub_id, &button);
248-
self.parent_state
249+
let inner = self.parent_state
249250
.show_submenu(ui.ctx(), sub_id, add_contents);
251+
InnerResponse::new(inner, button)
250252
}
251253
}
252254

0 commit comments

Comments
 (0)