Refactor KeyCode into Key and Location

This commit is contained in:
Héctor Ramón Jiménez 2024-01-16 13:28:00 +01:00
parent 534c7dd7b0
commit 64d1ce5532
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
24 changed files with 1277 additions and 461 deletions

View file

@ -1,6 +1,7 @@
//! Display a dropdown list of searchable and selectable options.
use crate::core::event::{self, Event};
use crate::core::keyboard;
use crate::core::keyboard::key;
use crate::core::layout::{self, Layout};
use crate::core::mouse;
use crate::core::overlay;
@ -436,14 +437,14 @@ where
}
if let Event::Keyboard(keyboard::Event::KeyPressed {
key_code,
key: keyboard::Key::Named(named_key),
modifiers,
..
}) = event
{
let shift_modifer = modifiers.shift();
match (key_code, shift_modifer) {
(keyboard::KeyCode::Enter, _) => {
match (named_key, shift_modifer) {
(key::Named::Enter, _) => {
if let Some(index) = &menu.hovered_option {
if let Some(option) =
state.filtered_options.options.get(*index)
@ -455,8 +456,7 @@ where
event_status = event::Status::Captured;
}
(keyboard::KeyCode::Up, _)
| (keyboard::KeyCode::Tab, true) => {
(key::Named::ArrowUp, _) | (key::Named::Tab, true) => {
if let Some(index) = &mut menu.hovered_option {
if *index == 0 {
*index = state
@ -492,8 +492,8 @@ where
event_status = event::Status::Captured;
}
(keyboard::KeyCode::Down, _)
| (keyboard::KeyCode::Tab, false)
(key::Named::ArrowDown, _)
| (key::Named::Tab, false)
if !modifiers.shift() =>
{
if let Some(index) = &mut menu.hovered_option {