Introduce subscription::Event
... and remove `PlatformSpecific` from `Event`
This commit is contained in:
parent
83296a73eb
commit
5d7dcf417c
13 changed files with 156 additions and 129 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use iced::event::{self, Event};
|
||||
use iced::event;
|
||||
use iced::widget::{center, text};
|
||||
use iced::{Element, Subscription};
|
||||
|
||||
|
|
@ -15,27 +15,20 @@ struct App {
|
|||
|
||||
#[derive(Debug, Clone)]
|
||||
enum Message {
|
||||
EventOccurred(Event),
|
||||
UrlReceived(String),
|
||||
}
|
||||
|
||||
impl App {
|
||||
fn update(&mut self, message: Message) {
|
||||
match message {
|
||||
Message::EventOccurred(event) => {
|
||||
if let Event::PlatformSpecific(
|
||||
event::PlatformSpecific::MacOS(event::MacOS::ReceivedUrl(
|
||||
url,
|
||||
)),
|
||||
) = event
|
||||
{
|
||||
self.url = Some(url);
|
||||
}
|
||||
Message::UrlReceived(url) => {
|
||||
self.url = Some(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn subscription(&self) -> Subscription<Message> {
|
||||
event::listen().map(Message::EventOccurred)
|
||||
event::listen_url().map(Message::UrlReceived)
|
||||
}
|
||||
|
||||
fn view(&self) -> Element<Message> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue