mirror of
https://github.com/emilk/egui.git
synced 2026-09-03 07:10:04 -04:00
Fix context_menu not closing when clicking widget (#5799)
The rerun timeline context menu wouldn't close when clicking outside, this fixes it
This commit is contained in:
@@ -273,11 +273,15 @@ impl<'a> Popup<'a> {
|
|||||||
/// In contrast to [`Self::menu`], this will open at the pointer position.
|
/// In contrast to [`Self::menu`], this will open at the pointer position.
|
||||||
pub fn context_menu(response: &Response) -> Self {
|
pub fn context_menu(response: &Response) -> Self {
|
||||||
Self::menu(response)
|
Self::menu(response)
|
||||||
.open_memory(
|
.open_memory(if response.secondary_clicked() {
|
||||||
response
|
Some(SetOpenCommand::Bool(true))
|
||||||
.secondary_clicked()
|
} else if response.clicked() {
|
||||||
.then_some(SetOpenCommand::Bool(true)),
|
// Explicitly close the menu if the widget was clicked
|
||||||
)
|
// Without this, the context menu would stay open if the user clicks the widget
|
||||||
|
Some(SetOpenCommand::Bool(false))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
})
|
||||||
.at_pointer_fixed()
|
.at_pointer_fixed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user