From 69c50c851193348ed3aab746678741f3cdda9fb3 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 12 Nov 2020 02:22:22 +0100 Subject: Introduce `event::Status` to `Subscription` --- examples/pane_grid/src/main.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'examples/pane_grid') 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 { - 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, + } }) } -- cgit