Refactor KeyCode into Key and Location
This commit is contained in:
parent
534c7dd7b0
commit
64d1ce5532
24 changed files with 1277 additions and 461 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue