summaryrefslogtreecommitdiffstats
path: root/examples/pane_grid/src/main.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-11-14 02:17:21 +0100
committerLibravatar GitHub <noreply@github.com>2020-11-14 02:17:21 +0100
commit62295f554b885b8d486b666bc10dc4ecdc78c7d6 (patch)
tree4758f6f17301b1a6c252a5a32248ae5498d1bb11 /examples/pane_grid/src/main.rs
parent73811c394a39c3816c67bffd2cf7d7a93c8803a9 (diff)
parentbf2d2561b8dde3e160438428b59c03c38a5f752a (diff)
downloadiced-62295f554b885b8d486b666bc10dc4ecdc78c7d6.tar.gz
iced-62295f554b885b8d486b666bc10dc4ecdc78c7d6.tar.bz2
iced-62295f554b885b8d486b666bc10dc4ecdc78c7d6.zip
Merge pull request #614 from hecrj/feature/event-capturing
Event capturing
Diffstat (limited to 'examples/pane_grid/src/main.rs')
-rw-r--r--examples/pane_grid/src/main.rs20
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,
+ }
})
}