Keys: the held-open canvas's Space is a press the held rule decides; a space a text field types is the field's

This commit is contained in:
aiongg
2026-11-12 22:54:16 +00:00
parent 164420d72f
commit 9f2fe6923e
3 changed files with 12 additions and 7 deletions
+3
View File
@@ -75,6 +75,9 @@ struct Press {
release: Option<Key>,
/// The place in `Batch::texts` of the text the press typed.
text: Option<usize>,
/// The Space of the canvas a dialog keeps open (`runtime::sampler`): no component's routing reads it, and only the
/// held rule decides whether its shortcut runs.
canvas: bool,
}
/// A key press, release or clipboard chord that the shortcut dispatcher may match, with the press that the
+6 -4
View File
@@ -206,9 +206,11 @@ impl Strip<'_> {
false
} else if key == Key::Space && self.canvas_space {
// The canvas has Space (`runtime::sampler`): only the shortcut dispatcher reads it, so the dialog's
// focused control does not activate.
// focused control does not activate. Its shortcut follows the held rule: a space a text field types is
// the field's.
batch.presses.push(Press { key, mods, repeat, in_egui: None, release: None, text: None, canvas: true });
if !repeat {
batch.shortcuts.push(Shortcut { input: *input, phase: FirePhase::Press, press: None });
batch.shortcuts.push(Shortcut { input: *input, phase: FirePhase::Press, press: Some(batch.presses.len() - 1) });
}
false
} else if (self.foreign && (bare_tab || escape)) || canvas_tab || canvas_edit {
@@ -223,7 +225,7 @@ impl Strip<'_> {
batch.tabs.push(TabPress { input: *input, repeat });
false
} else if ctrl_tab {
batch.presses.push(Press { key, mods, repeat, in_egui: None, release: None, text: None });
batch.presses.push(Press { key, mods, repeat, in_egui: None, release: None, text: None, canvas: false });
false
} else if let Some(WindowShortcut::Pane { forward }) = window_shortcut {
batch.nav.panes.push(forward);
@@ -238,7 +240,7 @@ impl Strip<'_> {
batch.menu.push(MenuKey::Letter(key.name().chars().next().unwrap_or('A')));
false
} else {
batch.presses.push(Press { key, mods, repeat, in_egui: None, release: None, text: None });
batch.presses.push(Press { key, mods, repeat, in_egui: None, release: None, text: None, canvas: false });
if !repeat {
batch.shortcuts.push(Shortcut { input: *input, phase: FirePhase::Press, press: Some(batch.presses.len() - 1) });
}
+3 -3
View File
@@ -54,7 +54,7 @@ pub(crate) fn begin(ctx: &Context, press_captured: bool) -> EscapeRouting {
// Whether a component took each text of the pass, as typing, type-ahead or digits.
let mut taken_texts = vec![false; batch.texts.len()];
if let Some(rec) = &target {
for (press, taken) in batch.presses.iter().zip(&mut consumed) {
for (press, taken) in batch.presses.iter().zip(&mut consumed).filter(|(press, _)| !press.canvas) {
*taken = if stale_repeat(&mut stale, press) {
Taken::Yes
} else {
@@ -73,7 +73,7 @@ pub(crate) fn begin(ctx: &Context, press_captured: bool) -> EscapeRouting {
// With nothing focused, a plain Enter submits to the window, as an unfocused Escape cancels: a tool's pending
// edit or a dialog's default button takes it. The arrows nudge the window's canvas content (a tool or the
// session control on a canvas), unless a modal layer is open.
for (press, taken) in batch.presses.iter().zip(&mut consumed) {
for (press, taken) in batch.presses.iter().zip(&mut consumed).filter(|(press, _)| !press.canvas) {
if press.key == Key::Enter && press.mods.is_none() && !press.repeat {
push(&mut routed, None, Intent::Submit, false);
*taken = Taken::Yes;
@@ -268,7 +268,7 @@ pub fn focus_holds(ctx: &Context, chord: Chord) -> bool {
if current(ctx, |stage| super::input::focused_claims(&record, stage)).contains(&chord) {
return true;
}
let press = Press { key: chord.key, mods: chord.mods, repeat: false, in_egui: None, release: None, text: None };
let press = Press { key: chord.key, mods: chord.mods, repeat: false, in_egui: None, release: None, text: None, canvas: false };
let driven = Driven::of(ctx, &rec);
let route = press_route(ctx, crate::runtime::windows::os_of(ctx), &rec, &press, driven.or_else(|| list_of_field(ctx, &rec)));
let taken = !matches!(route, PressRoute::Free);