diff options
author | 2024-01-17 08:12:44 +0100 | |
---|---|---|
committer | 2024-01-17 08:12:44 +0100 | |
commit | 0001a6d63642b299531ff089f961732a1bfa2339 (patch) | |
tree | 7b100257baf72dbceccf5c3343abf3a6b9f1db03 /examples/pane_grid/src | |
parent | c4ba657de86d7606587dad5124f435141258f570 (diff) | |
parent | 985acb2b1532b3e56161bd35201c4a2e21a86b85 (diff) | |
download | iced-0001a6d63642b299531ff089f961732a1bfa2339.tar.gz iced-0001a6d63642b299531ff089f961732a1bfa2339.tar.bz2 iced-0001a6d63642b299531ff089f961732a1bfa2339.zip |
Merge pull request #2169 from iced-rs/update-winit
Update `winit` to `0.29`
Diffstat (limited to 'examples/pane_grid/src')
-rw-r--r-- | examples/pane_grid/src/main.rs | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs index 96bb8e4e..d5e5bcbe 100644 --- a/examples/pane_grid/src/main.rs +++ b/examples/pane_grid/src/main.rs @@ -220,23 +220,26 @@ const PANE_ID_COLOR_FOCUSED: Color = Color::from_rgb( 0x47 as f32 / 255.0, ); -fn handle_hotkey(key_code: keyboard::KeyCode) -> Option<Message> { - use keyboard::KeyCode; +fn handle_hotkey(key: keyboard::Key) -> Option<Message> { + use keyboard::key::{self, Key}; use pane_grid::{Axis, Direction}; - let direction = match key_code { - KeyCode::Up => Some(Direction::Up), - KeyCode::Down => Some(Direction::Down), - KeyCode::Left => Some(Direction::Left), - KeyCode::Right => Some(Direction::Right), - _ => None, - }; + match key.as_ref() { + Key::Character("v") => Some(Message::SplitFocused(Axis::Vertical)), + Key::Character("h") => Some(Message::SplitFocused(Axis::Horizontal)), + Key::Character("w") => Some(Message::CloseFocused), + Key::Named(key) => { + let direction = match key { + key::Named::ArrowUp => Some(Direction::Up), + key::Named::ArrowDown => Some(Direction::Down), + key::Named::ArrowLeft => Some(Direction::Left), + key::Named::ArrowRight => Some(Direction::Right), + _ => None, + }; - match key_code { - KeyCode::V => Some(Message::SplitFocused(Axis::Vertical)), - KeyCode::H => Some(Message::SplitFocused(Axis::Horizontal)), - KeyCode::W => Some(Message::CloseFocused), - _ => direction.map(Message::FocusAdjacent), + direction.map(Message::FocusAdjacent) + } + _ => None, } } |