shortcut
This commit is contained in:
31
src/main.rs
31
src/main.rs
@@ -1,5 +1,6 @@
|
|||||||
mod polygon_draw;
|
mod polygon_draw;
|
||||||
use iced::advanced::subscription;
|
use iced::advanced::subscription;
|
||||||
|
use iced::keyboard::Modifiers;
|
||||||
use polygon_draw::Polygon;
|
use polygon_draw::Polygon;
|
||||||
|
|
||||||
mod music;
|
mod music;
|
||||||
@@ -429,11 +430,37 @@ impl MyApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn subscription(&self) -> iced::Subscription<Message> {
|
fn subscription(&self) -> iced::Subscription<Message> {
|
||||||
|
let subscr_key = event::listen_with(|event, status, _| match (event, status) {
|
||||||
|
(
|
||||||
|
Event::Keyboard(iced::keyboard::Event::KeyPressed {
|
||||||
|
key: Key::Character(c),
|
||||||
|
modifiers: Modifiers::CTRL,
|
||||||
|
..
|
||||||
|
}),
|
||||||
|
Status::Ignored,
|
||||||
|
) if c.as_ref() == "s" => Some(Message::Save),
|
||||||
|
(
|
||||||
|
Event::Keyboard(iced::keyboard::Event::KeyPressed {
|
||||||
|
key: Key::Named(Named::Space),
|
||||||
|
..
|
||||||
|
}),
|
||||||
|
Status::Ignored,
|
||||||
|
) => Some(Message::TogglePaused),
|
||||||
|
(
|
||||||
|
Event::Keyboard(iced::keyboard::Event::KeyPressed {
|
||||||
|
key: Key::Named(Named::ArrowUp),
|
||||||
|
..
|
||||||
|
}),
|
||||||
|
Status::Ignored,
|
||||||
|
) => Some(Message::ChangeDelta(0.0)),
|
||||||
|
_ => None,
|
||||||
|
});
|
||||||
if self.paused {
|
if self.paused {
|
||||||
Subscription::none()
|
subscr_key
|
||||||
} else {
|
} else {
|
||||||
iced::Subscription::batch([
|
iced::Subscription::batch([
|
||||||
iced::time::every(std::time::Duration::from_millis(16)).map(|_| Message::Tick)
|
subscr_key,
|
||||||
|
iced::time::every(std::time::Duration::from_millis(16)).map(|_| Message::Tick),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user