1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -04:00
Files
egui/crates
David M. Lary 32a63da580 Added Context::is_context_menu_open() (#3267)
I encountered a case where I needed to know if an egui context menu was
open, even if the mouse cursor was not in an egui area (full details in
discord).  I found that every resource I needed to detect that the menu
was open was either private, or pub(crate).  While it is possible to
wrap the `Response::context_menu()` in code to do state-tracking, it
becomes necessary to duplicate that code in every place you use a
context menu.

In this commit, I add `Context::is_context_menu_open()`.  Named similarly
to `Context::is_pointer_over_area()`, this method will return true if
any context menu is open.  This is possible because the context menu
uses a temp var with a fixed Id to store its state.  This method just
fetches the state, and interrogates it to see if there is a menu
present.

One helper method, `BarState::has_root()`, was added as all the fields
needed to perform the check were private to the `menu` module.

I've also updated the Context Menu demo to show the result of
`is_context_menu_open()` to verify the code functions as expected.
2023-08-22 15:35:15 +02:00
..
2023-08-11 13:54:02 +02:00
2023-08-22 14:35:18 +02:00
2023-04-18 15:52:45 +02:00
2023-08-15 17:17:39 +02:00
2023-08-15 17:17:39 +02:00