From 64a96ef3917d4e305a79fa5f460af5fc73eabcf8 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 10 Feb 2026 12:24:30 +0100 Subject: [PATCH] Stop ctrl+arrow etc from moving focus (#7897) Previously any pressing of arrow keys would move the focus, but now we check that there are no modifier keys pressed down --- crates/egui/src/memory/mod.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/crates/egui/src/memory/mod.rs b/crates/egui/src/memory/mod.rs index 9c91c1322..fbc8e6f68 100644 --- a/crates/egui/src/memory/mod.rs +++ b/crates/egui/src/memory/mod.rs @@ -543,22 +543,19 @@ impl Focus { .. } = event && let Some(cardinality) = match key { - crate::Key::ArrowUp => Some(FocusDirection::Up), - crate::Key::ArrowRight => Some(FocusDirection::Right), - crate::Key::ArrowDown => Some(FocusDirection::Down), - crate::Key::ArrowLeft => Some(FocusDirection::Left), + crate::Key::ArrowUp if !modifiers.any() => Some(FocusDirection::Up), + crate::Key::ArrowRight if !modifiers.any() => Some(FocusDirection::Right), + crate::Key::ArrowDown if !modifiers.any() => Some(FocusDirection::Down), + crate::Key::ArrowLeft if !modifiers.any() => Some(FocusDirection::Left), - crate::Key::Tab => { - if modifiers.shift { - Some(FocusDirection::Previous) - } else { - Some(FocusDirection::Next) - } - } - crate::Key::Escape => { + crate::Key::Tab if !modifiers.any() => Some(FocusDirection::Next), + crate::Key::Tab if modifiers.shift_only() => Some(FocusDirection::Previous), + + crate::Key::Escape if !modifiers.any() => { self.focused_widget = None; Some(FocusDirection::None) } + _ => None, } {