From 963219200c558f4b2b41f38c663e50f0d8ef3fb1 Mon Sep 17 00:00:00 2001 From: MarekSpodBiedry <73122968+MarekSpodBiedry@users.noreply.github.com> Date: Sat, 17 Oct 2026 07:45:31 +0200 Subject: [PATCH] Ctrl+Alt+letter that types a character no longer triggers the Ctrl shortcut (#1530) --- crates/ui-egui/src/grid.rs | 4 +++- crates/ui-egui/src/keymap.rs | 10 +++++++--- crates/ui-egui/tests/keyboard_shortcuts.rs | 11 +++++++++++ docs/ui-parity.md | 6 ++++-- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/grid.rs b/crates/ui-egui/src/grid.rs index 00e0c18be..b04a3e7a3 100644 --- a/crates/ui-egui/src/grid.rs +++ b/crates/ui-egui/src/grid.rs @@ -2681,7 +2681,9 @@ fn keyboard(app: &mut SheetApp, ctx: &egui::Context, resp: &egui::Response, geo: } Key::F9 => app.run_or_alert("formulas.calculateNow", json!({})), Key::F4 if !cmd => {} - _ if cmd => crate::ribbon::shortcut(app, key, m), + _ if cmd && !crate::keymap::altgr_text(ctx, m, ctx.os() == egui::os::OperatingSystem::Mac) => { + crate::ribbon::shortcut(app, key, m) + } _ => {} } } diff --git a/crates/ui-egui/src/keymap.rs b/crates/ui-egui/src/keymap.rs index 032db1a2d..92f7093d7 100644 --- a/crates/ui-egui/src/keymap.rs +++ b/crates/ui-egui/src/keymap.rs @@ -162,12 +162,16 @@ pub fn lookup(key: Key, physical: Option, m: Modifiers, mac: bool) -> Optio }) } +/// AltGr arrives as Ctrl+Alt on Windows: a key that also typed a character (AltGr+= is `~` on a German +/// layout; a user-defined Ctrl+Alt+A hotkey may type `ä`) is text, not a shortcut. +pub(crate) fn altgr_text(ctx: &egui::Context, m: Modifiers, mac: bool) -> bool { + !mac && m.alt && m.ctrl && ctx.input(|i| i.events.iter().any(|e| matches!(e, egui::Event::Text(_)))) +} + /// Handles a key press in the grid. Returns whether it was a shortcut. pub(crate) fn dispatch(app: &mut SheetApp, ctx: &egui::Context, key: Key, physical: Option, m: Modifiers, geo: &Geo, sh: &Sheet) -> bool { let mac = ctx.os() == egui::os::OperatingSystem::Mac; - // AltGr arrives as Ctrl+Alt on Windows: a key that also typed a character (AltGr+= is `~` - // on a German layout) is text, not a shortcut. - if !mac && m.alt && m.ctrl && ctx.input(|i| i.events.iter().any(|e| matches!(e, egui::Event::Text(_)))) { + if altgr_text(ctx, m, mac) { return false; } let Some(shortcut) = lookup(key, physical, m, mac) else { return false }; diff --git a/crates/ui-egui/tests/keyboard_shortcuts.rs b/crates/ui-egui/tests/keyboard_shortcuts.rs index c0a1307b3..7693d149f 100644 --- a/crates/ui-egui/tests/keyboard_shortcuts.rs +++ b/crates/ui-egui/tests/keyboard_shortcuts.rs @@ -214,3 +214,14 @@ fn alt_down_only_opens_enabled_table_filter_buttons() { assert_eq!(h.state().session.active().unwrap().selection.active.a1(), "B1"); } } + +#[test] +fn ctrl_alt_letter_that_typed_text_is_not_select_all() { + let mut h = harness(book("B2")); + let ctrl_alt = Modifiers { alt: true, ..CTRL }; + h.input_mut().events.push(Event::Key { key: Key::A, physical_key: Some(Key::A), pressed: true, repeat: false, modifiers: ctrl_alt }); + h.input_mut().events.push(Event::Text("\u{e4}".into())); + h.run_steps(2); + assert_eq!(h.state().session.active().unwrap().selection.current().a1(), "B2"); + assert_eq!(h.state().editor.as_ref().unwrap().text, "\u{e4}"); +} diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 22e221e69..24d2774d6 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (horizontal scrollbar in the sheet tab bar, #840) · **Target:** Microsoft Excel (Microsoft 365), Excel for Mac 16.113.4 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-17 · **Change:** minor (Ctrl+Alt+letter that types a character skips Ctrl shortcuts, #1530) · **Target:** Microsoft Excel (Microsoft 365), Excel for Mac 16.113.4 Interaction, controls and feel, against Excel. Part of [target-app-parity.md](target-app-parity.md). **UI/UX fidelity: ~55% ready, 50–80 h** (estimated). Ribbon command coverage is measured @@ -129,7 +129,8 @@ otherwise. Number-format and border keys match the physical key (Ctrl+Shift+4, w | — | Cmd+= (calculate), Cmd+T (references while editing; F4 works), Shift+F7, Cmd+Shift+L | Mac-only extras | missing (Cmd+= is egui's zoom key; no thesaurus or Modify Cell Style) | On Windows, AltGr arrives as Ctrl+Alt: a Ctrl+Alt key that also types a character is treated as -text, so AltGr symbols (e.g. `~` on a German layout) never trigger a shortcut. +text, so AltGr symbols (e.g. `~` on a German layout) and user-defined Ctrl+Alt+letter hotkeys that type +a character (e.g. Ctrl+Alt+A for `ä`) never trigger a shortcut, Ctrl+letter ones like Select All included. ## Dialogs @@ -161,6 +162,7 @@ scrollbar bugs 2–4 · pixel/feel pass against observed Excel 7–12. | Date | Change | Summary | |---|---|---| +| 2026-10-17 | minor | A Ctrl+Alt+letter key that types a character (a user-defined Windows hotkey such as Ctrl+Alt+A for `ä`) types it instead of running the Ctrl+letter shortcut, e.g. Select All (#1530) | | 2026-10-12 | minor | The File view's recent list tells when each workbook was last changed, read off the UI thread | | 2026-10-13 | minor | Horizontal scrollbar in the sheet tab bar: drag, track click pages, frozen columns excluded from the page (#840) | | 2026-10-12 | minor | Ctrl+wheel zoom steps along a ladder of percentages about 20% apart that never skips 100%, gliding to each step with animations on, so a notch out undoes a notch in (it drifted: 100 → 122 → 101); Excel steps 15 points, see decisions.md |