diff options
author | 2024-03-16 17:09:00 +0100 | |
---|---|---|
committer | 2024-03-16 17:09:00 +0100 | |
commit | 503a48e89977437bf8b7bf485f416a15a2e83ed0 (patch) | |
tree | 30306bbaee7a31090ace9d7725d46c2c0027fe6b /examples/events/src | |
parent | 0524e9b4571d264018656418f02a1f9e27e268d7 (diff) | |
parent | cfc0383bbfff083786840e3f1fd499e5991fa629 (diff) | |
download | iced-503a48e89977437bf8b7bf485f416a15a2e83ed0.tar.gz iced-503a48e89977437bf8b7bf485f416a15a2e83ed0.tar.bz2 iced-503a48e89977437bf8b7bf485f416a15a2e83ed0.zip |
Merge pull request #2331 from iced-rs/program-api
`Program` API
Diffstat (limited to '')
-rw-r--r-- | examples/events/src/main.rs | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/examples/events/src/main.rs b/examples/events/src/main.rs index d5d496c7..6eb11cb8 100644 --- a/examples/events/src/main.rs +++ b/examples/events/src/main.rs @@ -1,21 +1,14 @@ 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 - Iced", Events::update, Events::view) + .subscription(Events::subscription) + .ignore_close_request() + .run() } #[derive(Debug, Default)] @@ -31,20 +24,7 @@ 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>) { - (Events::default(), Command::none()) - } - - fn title(&self) -> String { - String::from("Events - Iced") - } - +impl Events { fn update(&mut self, message: Message) -> Command<Message> { match message { Message::EventOccurred(event) if self.enabled => { |