Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

Merge remote-tracking branch 'origin/main' into menu-bar-native-behaviour

Egon 50005bcc9ed1e988
diff --cc crates/ui-egui/src/menus.rs
index 5be1e80a4,26a7b66f6..605582ba2
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@@ -2063,19 -2008,7 +2076,19 @@@ pub fn menu_bar(app: &mut EffectcraftAp
});
});
crate::menu_keys::handle(&ctx, &nav);
+ // egui leaves the closing to us (`IgnoreClicks`), so the menus close here: at once on a press
+ // outside them (the press itself still reaches the widget below) and when the window loses
+ // focus. The pointer leaving the window closes nothing: moving onto the OS title bar fires
+ // the cursor-left event and the platform forwards none of its clicks to egui, so there is no
+ // click to close on — and a graze or a stay must not drop the menu, as in native apps.
+ if let Some(top) = nav.open_popup(&ctx) {
+ let focus_lost = ctx.input(|i| i.events.iter().any(|e| matches!(e, egui::Event::WindowFocused(false))));
+ let outside_press = ctx.input(|i| i.pointer.any_pressed() && i.pointer.interact_pos().is_some_and(|p| !nav.covers(p)));
+ if focus_lost || outside_press {
+ egui::Popup::close_id(&ctx, top);
+ }
+ }
- if let Some((id, params)) = clicked
+ if let Some((id, params)) = clicked.map(|(id, params)| menu_choice(app, id, params))
&& let Err(e) = invoke(app, &ctx, &id, if params.is_null() { json!({}) } else { params })
{
app.ui.status = e;