I have an egui application with a menu bar along the top of the window that has a File menu with a few options (egui::menu::bar(ui, |ui| { ui.menu_button("File", |ui| { /* buttons */ }); })
). I've noticed that clicking on one of the options in the menu doesn't close it; the menu stays open until you click outside of it or press Esc. Is there any way to get the menu to close after you click an option? I've been perusing the docs and haven't found any reference to a way to explicitly open or close a menu. I also considered the possibility of trying to fake an input event to get it to close, but I haven't found a way to do that either, at least not within egui itself.
There seems to be a close_menu
method in UI
: Ui in egui - Rust
2 Likes
Wow I spent ages searching the GitHub issues and googling variations of "egui close menu", "egui menu close", etc. and none of those turned up any reference to this simple and obvious method. Maybe LLMs have atrophied my Google skills. Hopefully this thread turns up for the next poor sap who tries my same queries. Thank you!
1 Like
FWIW, I didn't get any good search results either. I had to go to egui's documentation and checked each struct's (menu
, ui
, etc.) methods.