diff options
author | 2024-03-16 05:33:47 +0100 | |
---|---|---|
committer | 2024-03-16 05:33:47 +0100 | |
commit | c22269bff3085012d326a0df77bf27ad5bcb41b7 (patch) | |
tree | 1083f21d012ab2bac88fb51537d4dc431bc7f170 /examples/events | |
parent | 0524e9b4571d264018656418f02a1f9e27e268d7 (diff) | |
download | iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.tar.gz iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.tar.bz2 iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.zip |
Introduce `Program` API
Diffstat (limited to 'examples/events')
-rw-r--r-- | examples/events/src/main.rs | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/examples/events/src/main.rs b/examples/events/src/main.rs index d5d496c7..4ac57fc6 100644 --- a/examples/events/src/main.rs +++ b/examples/events/src/main.rs @@ -1,21 +1,15 @@ use iced::alignment; use iced::event::{self, Event}; -use iced::executor; use iced::widget::{button, checkbox, container, text, Column}; use iced::window; -use iced::{ - Alignment, Application, Command, Element, Length, Settings, Subscription, - Theme, -}; +use iced::{Alignment, Command, Element, Length, Subscription}; pub fn main() -> iced::Result { - Events::run(Settings { - window: window::Settings { - exit_on_close_request: false, - ..window::Settings::default() - }, - ..Settings::default() - }) + iced::application(Events::new, Events::update, Events::view) + .title("Events - Iced") + .subscription(Events::subscription) + .ignore_close_request() + .run() } #[derive(Debug, Default)] @@ -31,20 +25,11 @@ enum Message { Exit, } -impl Application for Events { - type Message = Message; - type Theme = Theme; - type Executor = executor::Default; - type Flags = (); - - fn new(_flags: ()) -> (Events, Command<Message>) { +impl Events { + fn new() -> (Events, Command<Message>) { (Events::default(), Command::none()) } - fn title(&self) -> String { - String::from("Events - Iced") - } - fn update(&mut self, message: Message) -> Command<Message> { match message { Message::EventOccurred(event) if self.enabled => { |