core: KeyPress events have precedence over tabbing

When there's a button that handles KeyPress "Tab" event (code 18),
the tabbing should not be performed.
This commit is contained in:
Kamil Jarosz 2024-05-22 13:39:03 +02:00 committed by Adrian Wielgosik
parent d996f12d58
commit 0edb7d6890
1 changed files with 13 additions and 12 deletions

View File

@ -1125,6 +1125,19 @@ impl Player {
} }
} }
// KeyPress events also take precedence over tabbing.
if !key_press_handled {
if let PlayerEvent::KeyDown {
key_code: KeyCode::Tab,
..
} = event
{
let reversed = context.input.is_key_down(KeyCode::Shift);
let tracker = context.focus_tracker;
tracker.cycle(context, reversed);
}
}
// KeyPress events also take precedence over keyboard navigation. // KeyPress events also take precedence over keyboard navigation.
// Note that keyboard navigation works only when the highlight is visible. // Note that keyboard navigation works only when the highlight is visible.
if !key_press_handled && context.focus_tracker.highlight().is_visible() { if !key_press_handled && context.focus_tracker.highlight().is_visible() {
@ -1200,18 +1213,6 @@ impl Player {
} }
} }
if let PlayerEvent::KeyDown {
key_code: KeyCode::Tab,
..
} = event
{
self.mutate_with_update_context(|context| {
let reversed = context.input.is_key_down(KeyCode::Shift);
let tracker = context.focus_tracker;
tracker.cycle(context, reversed);
});
}
if self.should_reset_highlight(event) { if self.should_reset_highlight(event) {
self.mutate_with_update_context(|context| { self.mutate_with_update_context(|context| {
context.focus_tracker.reset_highlight(); context.focus_tracker.reset_highlight();