core: Allow pressing buttons with keyboard
This patch allows the keyboard to be used (Enter/Space) to press buttons.
This commit is contained in:
parent
18d9035685
commit
da9c9527e5
|
@ -1125,6 +1125,25 @@ impl Player {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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() {
|
||||||
|
if let Some(focus) = context.focus_tracker.get() {
|
||||||
|
if matches!(
|
||||||
|
event,
|
||||||
|
PlayerEvent::KeyDown {
|
||||||
|
key_code: KeyCode::Return,
|
||||||
|
..
|
||||||
|
} | PlayerEvent::TextInput { codepoint: ' ' }
|
||||||
|
) {
|
||||||
|
// The button/clip is pressed and then immediately released.
|
||||||
|
// We do not have to wait for KeyUp.
|
||||||
|
focus.handle_clip_event(context, ClipEvent::Press);
|
||||||
|
focus.handle_clip_event(context, ClipEvent::Release);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Self::run_actions(context);
|
Self::run_actions(context);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue