emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
22.44k stars 1.6k forks source link

Allow developers to check if a menu of a menu_button is currently opened #2375

Open lukas-kirschner opened 1 year ago

lukas-kirschner commented 1 year ago

Is your feature request related to a problem? Please describe.

I am programming a game using bevy and bevy_egui. My map editor uses egui to show selector buttons for different tiles that can be placed on the game board.

Since some of the tiles have different variants, I show those tiles in a drop-down menu: Screenshot_20221203_184624

When a user clicks on a button in the dropdown menu, the click is also registered as a click on the GameBoard, placing a tile on the board. This bug has already been reported here: https://github.com/bevyengine/bevy/issues/3570 - To work around that bug, I am trying to set a flag in my mouse handlers that change their values when a menu is opened.

To set this flag, I currently do not see any possibility of getting the menu open state from my Ui object (menu_state is private in Ui, unfortunately).

Describe the solution you'd like

I could see a solution by either making menu_state public, or by adding a menu_is_open() function in Ui

Describe alternatives you've considered

Additional context

The bug I am trying to fix is reported here: https://github.com/lukas-kirschner/Exodus/issues/44

abey79 commented 9 months ago

I've found myself needing to work around this one as well. It would be useful to know: