diff --git a/crates/ui-contract/src/runtime/focus.rs b/crates/ui-contract/src/runtime/focus.rs index 31745019c..d4bb8d062 100644 --- a/crates/ui-contract/src/runtime/focus.rs +++ b/crates/ui-contract/src/runtime/focus.rs @@ -345,6 +345,14 @@ pub(crate) fn is_canvas_member(ctx: &Context, rec: &StopRec) -> bool { }) } +/// Whether a bare Tab in `viewport` has no stop to move the focus to: the window's last pass registered no stop (the +/// app's focusable egui widgets are stops too, `take_app_widgets`) and nothing held the focus at its end. Such a Tab +/// stays in egui's input for the app's own binding. Read by the input hook, before the begin hook rotates the +/// registrations. +pub(crate) fn tab_has_no_stop(ctx: &Context, viewport: ViewportId) -> bool { + with_viewport(ctx, viewport, |state| state.stops.is_empty() && state.focus_now.is_none()) +} + /// How many stops the running pass has registered so far. pub(crate) fn stop_count(ctx: &Context) -> usize { take_app_widgets(ctx, None); diff --git a/crates/ui-contract/src/runtime/keys/input.rs b/crates/ui-contract/src/runtime/keys/input.rs index 4a1177e2a..10fc04150 100644 --- a/crates/ui-contract/src/runtime/keys/input.rs +++ b/crates/ui-contract/src/runtime/keys/input.rs @@ -45,8 +45,9 @@ struct Strip<'a> { /// An app's own egui widget or popup has the focus (`FocusedRecord::foreign`): Escape, the plain Enter and the /// clipboard events are its own, and no window intent comes of them. foreign: bool, - /// A bare Tab is egui's (`FocusedRecord::tab_in_egui`): an app's own popup is open, or the app's own focused widget - /// keeps Tab by its egui key filter. + /// A bare Tab is egui's: an app's own popup is open, or the app's own focused widget keeps Tab by its egui key + /// filter (`FocusedRecord::tab_in_egui`), or the window has no stop to move the focus to and nothing focused + /// (`focus::tab_has_no_stop`), so the Tab is the app's own binding's. tab_in_egui: bool, /// The focused stop is the app's own egui widget (`Stop::host`, `FocusedRecord::host`), which reads its keys from /// egui: its Escape stays there, as an app's own focused widget's does. Tab and the arrows follow its `KeyUse`, as @@ -665,6 +666,7 @@ pub(crate) fn input_hook(ctx: &Context, input: &RawInput, events: &mut Vec