Hide hover UI when showing the context menu (#4138)
This PR hides the hover UI for a given widget whenever a corresponding context menu is opened. Fixes: - https://github.com/rerun-io/rerun/issues/5310
This commit is contained in:
parent
ca1f453c47
commit
a1d5145c16
|
|
@ -230,6 +230,13 @@ pub(crate) fn context_menu(
|
||||||
inner_response
|
inner_response
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns `true` if the context menu is opened for this widget.
|
||||||
|
pub(crate) fn context_menu_opened(response: &Response) -> bool {
|
||||||
|
let menu_id = Id::new(CONTEXT_MENU_ID_STR);
|
||||||
|
let bar_state = BarState::load(&response.ctx, menu_id);
|
||||||
|
bar_state.is_menu_open(response.id)
|
||||||
|
}
|
||||||
|
|
||||||
/// Stores the state for the context menu.
|
/// Stores the state for the context menu.
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
pub(crate) struct MenuRootManager {
|
pub(crate) struct MenuRootManager {
|
||||||
|
|
|
||||||
|
|
@ -534,6 +534,10 @@ impl Response {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.context_menu_opened() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if self.enabled {
|
if self.enabled {
|
||||||
if !self.hovered || !self.ctx.input(|i| i.pointer.has_pointer()) {
|
if !self.hovered || !self.ctx.input(|i| i.pointer.has_pointer()) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -849,6 +853,13 @@ impl Response {
|
||||||
menu::context_menu(self, add_contents)
|
menu::context_menu(self, add_contents)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns whether a context menu is currently open for this widget.
|
||||||
|
///
|
||||||
|
/// See [`Self::context_menu`].
|
||||||
|
pub fn context_menu_opened(&self) -> bool {
|
||||||
|
menu::context_menu_opened(self)
|
||||||
|
}
|
||||||
|
|
||||||
/// Draw a debug rectangle over the response displaying the response's id and whether it is
|
/// Draw a debug rectangle over the response displaying the response's id and whether it is
|
||||||
/// enabled and/or hovered.
|
/// enabled and/or hovered.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue