1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -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
&& 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,
}
{