1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 21:30:03 -04:00

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
This commit is contained in:
Emil Ernerfeldt
2026-02-10 12:24:30 +01:00
committed by GitHub
parent 3cd52881b4
commit 64a96ef391

View File

@@ -543,22 +543,19 @@ impl Focus {
.. ..
} = event } = event
&& let Some(cardinality) = match key { && let Some(cardinality) = match key {
crate::Key::ArrowUp => Some(FocusDirection::Up), crate::Key::ArrowUp if !modifiers.any() => Some(FocusDirection::Up),
crate::Key::ArrowRight => Some(FocusDirection::Right), crate::Key::ArrowRight if !modifiers.any() => Some(FocusDirection::Right),
crate::Key::ArrowDown => Some(FocusDirection::Down), crate::Key::ArrowDown if !modifiers.any() => Some(FocusDirection::Down),
crate::Key::ArrowLeft => Some(FocusDirection::Left), crate::Key::ArrowLeft if !modifiers.any() => Some(FocusDirection::Left),
crate::Key::Tab => { crate::Key::Tab if !modifiers.any() => Some(FocusDirection::Next),
if modifiers.shift { crate::Key::Tab if modifiers.shift_only() => Some(FocusDirection::Previous),
Some(FocusDirection::Previous)
} else { crate::Key::Escape if !modifiers.any() => {
Some(FocusDirection::Next)
}
}
crate::Key::Escape => {
self.focused_widget = None; self.focused_widget = None;
Some(FocusDirection::None) Some(FocusDirection::None)
} }
_ => None, _ => None,
} }
{ {