Skip to content

Commit

Permalink
core: KeyPress events have precedence over tabbing
Browse files Browse the repository at this point in the history
When there's a button that handles KeyPress "Tab" event (code 18),
the tabbing should not be performed.
  • Loading branch information
kjarosh authored and adrian17 committed May 24, 2024
1 parent d996f12 commit 0edb7d6
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions core/src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
// Note that keyboard navigation works only when the highlight is visible.
if !key_press_handled && context.focus_tracker.highlight().is_visible() {
Expand Down Expand Up @@ -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) {
self.mutate_with_update_context(|context| {
context.focus_tracker.reset_highlight();
Expand Down

0 comments on commit 0edb7d6

Please sign in to comment.