diff options
author | 2023-09-07 03:10:57 +0200 | |
---|---|---|
committer | 2023-09-07 03:10:57 +0200 | |
commit | c8fed143eb14d790da0592c5e24c741f6fda101e (patch) | |
tree | cf7f002d1ac7e2a8c036f1d420238d69ab45407b /examples/pane_grid/src | |
parent | a56b25b9096d47ada3c4349f5b91110dfaa92bf6 (diff) | |
parent | d21f0698b505d699c44e9414f902dbeca9474e39 (diff) | |
download | iced-c8fed143eb14d790da0592c5e24c741f6fda101e.tar.gz iced-c8fed143eb14d790da0592c5e24c741f6fda101e.tar.bz2 iced-c8fed143eb14d790da0592c5e24c741f6fda101e.zip |
Merge pull request #2073 from iced-rs/event-helpers
Add `keyboard` subscriptions and rename `subscription::events` to `event::listen`
Diffstat (limited to 'examples/pane_grid/src')
-rw-r--r-- | examples/pane_grid/src/main.rs | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs index 04896e20..af87e2c0 100644 --- a/examples/pane_grid/src/main.rs +++ b/examples/pane_grid/src/main.rs @@ -1,8 +1,6 @@ use iced::alignment::{self, Alignment}; -use iced::event::{self, Event}; use iced::executor; use iced::keyboard; -use iced::subscription; use iced::theme::{self, Theme}; use iced::widget::pane_grid::{self, PaneGrid}; use iced::widget::{ @@ -146,18 +144,12 @@ impl Application for Example { } fn subscription(&self) -> Subscription<Message> { - subscription::events_with(|event, status| { - if let event::Status::Captured = status { + keyboard::on_key_press(|key_code, modifiers| { + if !modifiers.command() { return None; } - match event { - Event::Keyboard(keyboard::Event::KeyPressed { - modifiers, - key_code, - }) if modifiers.command() => handle_hotkey(key_code), - _ => None, - } + handle_hotkey(key_code) }) } |