Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

fix(menus): Alt held through a shortcut no longer puts the keyboard on the menu bar, so Enter reaches the dialog (#7481)

Korg1ch8c6166849ae1
diff --git a/crates/ui-egui/src/menu_keys.rs b/crates/ui-egui/src/menu_keys.rs
index 83fe21a55..d033d7aec 100644
--- a/crates/ui-egui/src/menu_keys.rs
+++ b/crates/ui-egui/src/menu_keys.rs
@@ -208,7 +208,12 @@ impl Keys {
}
let events = ctx.input(|i| i.events.clone());
let mut tap = false;
- for e in &events {
+ // The tap is judged on every event of the frame, also those another handler consumed
+ // before the bar's turn: the shortcuts run first, so Ctrl+Alt+I (Image Size) left no
+ // trace in `events`, and releasing Alt counted as a tap that put the keyboard on the bar;
+ // Enter then opened File instead of confirming the dialog (#7481).
+ let raw = ctx.input(|i| i.raw.events.clone());
+ for e in &raw {
match e {
Event::Key { key: Key::AltLeft | Key::AltRight, pressed: true, .. } => {
self.alt_down = true;