From 787bc351778e78c4f701cc480e567dd02ee3184c Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 18 Nov 2026 12:21:55 +0000 Subject: [PATCH] owed by ribbon-w5: FocusedRecord::menu_bar as Option, register_menu_bar(ctx, id) --- crates/ui-contract/src/contract/cx/focus.rs | 2 +- crates/ui-contract/src/runtime/focus.rs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/ui-contract/src/contract/cx/focus.rs b/crates/ui-contract/src/contract/cx/focus.rs index 9afa0be39..887657105 100644 --- a/crates/ui-contract/src/contract/cx/focus.rs +++ b/crates/ui-contract/src/contract/cx/focus.rs @@ -100,7 +100,7 @@ impl Focus for CxCore<'_> { } fn register_menu_bar(&mut self) { - focus::register_menu_bar(&self.ctx); + focus::register_menu_bar(&self.ctx, self.id); } fn take_menu_keys(&mut self) -> Vec { diff --git a/crates/ui-contract/src/runtime/focus.rs b/crates/ui-contract/src/runtime/focus.rs index 8448fdb84..e5ff55a24 100644 --- a/crates/ui-contract/src/runtime/focus.rs +++ b/crates/ui-contract/src/runtime/focus.rs @@ -80,7 +80,8 @@ pub(crate) struct FocusedRecord { pub(crate) menu: Option, /// The focused stop switches pages with Ctrl+Tab. pub(crate) pages: bool, - pub(crate) menu_bar: bool, + /// The window's registered menu bar, by the id that registered it (owed by ribbon-w5). + pub(crate) menu_bar: Option, /// egui focus is on a widget no framework component made, or an egui popup is open, and no framework press or /// drag is captured: an app's own focused widget or popup keeps the keys a focused component keeps (Tab, Escape, /// the clipboard events). Written by the end hook after its focus moves. @@ -150,7 +151,7 @@ pub(crate) struct State { pub(super) entered: bool, pub(crate) visible: bool, pub(crate) record: FocusedRecord, - pub(super) menu_bar: bool, + pub(super) menu_bar: Option, /// The menu bar that took focus and the stop it took focus from, for the bar or a menu pick to give back. pub(super) bar_return: Option<(Id, StopKey)>, pub(crate) press: press::PressState, @@ -428,8 +429,8 @@ pub(crate) fn pop_scope(ctx: &Context) { } /// Registers that a menu bar can take the menu-bar keys of the next input hook (spec 9.7). -pub(crate) fn register_menu_bar(ctx: &Context) { - with(ctx, |state| state.menu_bar = true); +pub(crate) fn register_menu_bar(ctx: &Context, id: Id) { + with(ctx, |state| state.menu_bar = Some(id)); } /// A registered menu bar takes the keyboard (F10, a lone Alt): focus moves to `target`, a stop of the bar, in this