diff options
| author | 2024-06-14 01:47:39 +0200 | |
|---|---|---|
| committer | 2024-06-14 01:47:39 +0200 | |
| commit | a25b1af45690bdd8e1cbb20ee3a5b1c4342de455 (patch) | |
| tree | 432044cf682dd73d1019a2f964749e78db178865 /examples/multi_window/src | |
| parent | e6d0b3bda5042a1017a5944a5227c97e0ed6caf9 (diff) | |
| download | iced-a25b1af45690bdd8e1cbb20ee3a5b1c4342de455.tar.gz iced-a25b1af45690bdd8e1cbb20ee3a5b1c4342de455.tar.bz2 iced-a25b1af45690bdd8e1cbb20ee3a5b1c4342de455.zip | |
Replace `Command` with a new `Task` API with chain support
Diffstat (limited to '')
| -rw-r--r-- | examples/multi_window/src/main.rs | 20 | 
1 files changed, 10 insertions, 10 deletions
| diff --git a/examples/multi_window/src/main.rs b/examples/multi_window/src/main.rs index eb74c94a..e15f8759 100644 --- a/examples/multi_window/src/main.rs +++ b/examples/multi_window/src/main.rs @@ -6,7 +6,7 @@ use iced::widget::{  };  use iced::window;  use iced::{ -    Alignment, Command, Element, Length, Point, Settings, Subscription, Theme, +    Alignment, Element, Length, Point, Settings, Subscription, Task, Theme,      Vector,  }; @@ -48,13 +48,13 @@ impl multi_window::Application for Example {      type Theme = Theme;      type Flags = (); -    fn new(_flags: ()) -> (Self, Command<Message>) { +    fn new(_flags: ()) -> (Self, Task<Message>) {          (              Example {                  windows: HashMap::from([(window::Id::MAIN, Window::new(1))]),                  next_window_pos: window::Position::Default,              }, -            Command::none(), +            Task::none(),          )      } @@ -65,14 +65,14 @@ impl multi_window::Application for Example {              .unwrap_or("Example".to_string())      } -    fn update(&mut self, message: Message) -> Command<Message> { +    fn update(&mut self, message: Message) -> Task<Message> {          match message {              Message::ScaleInputChanged(id, scale) => {                  let window =                      self.windows.get_mut(&id).expect("Window not found!");                  window.scale_input = scale; -                Command::none() +                Task::none()              }              Message::ScaleChanged(id, scale) => {                  let window = @@ -83,7 +83,7 @@ impl multi_window::Application for Example {                      .unwrap_or(window.current_scale)                      .clamp(0.5, 5.0); -                Command::none() +                Task::none()              }              Message::TitleChanged(id, title) => {                  let window = @@ -91,12 +91,12 @@ impl multi_window::Application for Example {                  window.title = title; -                Command::none() +                Task::none()              }              Message::CloseWindow(id) => window::close(id),              Message::WindowClosed(id) => {                  self.windows.remove(&id); -                Command::none() +                Task::none()              }              Message::WindowOpened(id, position) => {                  if let Some(position) = position { @@ -108,13 +108,13 @@ impl multi_window::Application for Example {                  if let Some(window) = self.windows.get(&id) {                      text_input::focus(window.input_id.clone())                  } else { -                    Command::none() +                    Task::none()                  }              }              Message::NewWindow => {                  let count = self.windows.len() + 1; -                let (id, spawn_window) = window::spawn(window::Settings { +                let (id, spawn_window) = window::open(window::Settings {                      position: self.next_window_pos,                      exit_on_close_request: count % 2 == 0,                      ..Default::default() | 
