From 8f36bcbf141eff02c32c67f9aba158a96099faf2 Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Sat, 28 Nov 2026 01:17:26 -0700 Subject: [PATCH] fix(web): Alt with a plain tool letter stays the browser's (M8) On a Mac Option+letter types a character; the macOS gate's new test caught the editor taking it. --- src/platform.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/platform.rs b/src/platform.rs index b3cfc496..1419b665 100644 --- a/src/platform.rs +++ b/src/platform.rs @@ -235,8 +235,9 @@ pub fn claims_key(bound: &[(egui::Modifiers, egui::Key)], alt_menus: bool, press if !chorded && !function { return false; } - // As egui matches a shortcut: extra Shift or Alt held still presses it. - bound.iter().any(|(m, k)| *k == key && pressed.matches_logically(*m)) + // As egui matches a shortcut: extra Shift or Alt held still presses it. But a plain letter's + // binding (a tool key) is not a chord to take with Alt held: on a Mac that types a character. + bound.iter().any(|(m, k)| *k == key && (function || m.ctrl || m.command || m.alt) && pressed.matches_logically(*m)) } pub fn set_mac_glyphs(available: bool) { @@ -1480,6 +1481,7 @@ mod tests { assert!(claims(Modifiers::SHIFT, Key::F5), "as egui matches it: Shift held still presses F5"); assert!(!claims(Modifiers::NONE, Key::F12) && !claims(ctrl, Key::T) && !claims(Modifiers::ALT, Key::D), "unused keys are the browser's"); assert!(!claims(Modifiers::NONE, Key::V), "a tool letter is typing in a text field"); + assert!(!claims(Modifiers::ALT, Key::V), "and with Alt it types a character on a Mac"); assert!(!claims(ctrl, Key::V) && !claims(ctrl | Modifiers::SHIFT, Key::V), "paste arrives as the browser's event"); assert!(claims_key(&bound, true, Modifiers::ALT, None), "Alt alone is the editor's menu bar"); assert!(!claims_key(&bound, false, Modifiers::ALT, None), "but not on a Mac, where Alt opens no menu");