diff options
author | 2020-11-12 02:22:22 +0100 | |
---|---|---|
committer | 2020-11-12 02:22:22 +0100 | |
commit | 69c50c851193348ed3aab746678741f3cdda9fb3 (patch) | |
tree | fe8fe23c2de55cbb3af21e0682a9a51121b2b357 /examples | |
parent | 33d80b5a0b8b5b2837c99be2a152bdeb73ca60c8 (diff) | |
download | iced-69c50c851193348ed3aab746678741f3cdda9fb3.tar.gz iced-69c50c851193348ed3aab746678741f3cdda9fb3.tar.bz2 iced-69c50c851193348ed3aab746678741f3cdda9fb3.zip |
Introduce `event::Status` to `Subscription`
Diffstat (limited to 'examples')
-rw-r--r-- | examples/pane_grid/src/main.rs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs index e786eadd..f986cc8d 100644 --- a/examples/pane_grid/src/main.rs +++ b/examples/pane_grid/src/main.rs @@ -3,7 +3,7 @@ use iced::{ Button, Column, Command, Container, Element, HorizontalAlignment, Length, PaneGrid, Scrollable, Settings, Subscription, Text, }; -use iced_native::{subscription, Event}; +use iced_native::{event, subscription, Event}; pub fn main() -> iced::Result { Example::run(Settings::default()) @@ -119,12 +119,18 @@ impl Application for Example { } fn subscription(&self) -> Subscription<Message> { - subscription::events_with(|event| match event { - Event::Keyboard(keyboard::Event::KeyPressed { - modifiers, - key_code, - }) if modifiers.is_command_pressed() => handle_hotkey(key_code), - _ => None, + subscription::events_with(|event, status| { + if let event::Status::Captured = status { + return None; + } + + match event { + Event::Keyboard(keyboard::Event::KeyPressed { + modifiers, + key_code, + }) if modifiers.is_command_pressed() => handle_hotkey(key_code), + _ => None, + } }) } |