Introduce event::Status to Subscription
This commit is contained in:
parent
33d80b5a0b
commit
69c50c8511
6 changed files with 50 additions and 29 deletions
|
|
@ -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,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue