From ae517b9fa033ba75df5fc6ce766698fab22504fa Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 11 Mar 2021 03:38:20 +0100 Subject: Add `clipboard` argument to `Application::update` --- src/application.rs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src/application.rs') diff --git a/src/application.rs b/src/application.rs index 3b690a7c..162fde84 100644 --- a/src/application.rs +++ b/src/application.rs @@ -1,5 +1,7 @@ use crate::window; -use crate::{Color, Command, Element, Executor, Settings, Subscription}; +use crate::{ + Clipboard, Color, Command, Element, Executor, Settings, Subscription, +}; /// An interactive cross-platform application. /// @@ -57,7 +59,7 @@ use crate::{Color, Command, Element, Executor, Settings, Subscription}; /// says "Hello, world!": /// /// ```no_run -/// use iced::{executor, Application, Command, Element, Settings, Text}; +/// use iced::{executor, Application, Clipboard, Command, Element, Settings, Text}; /// /// pub fn main() -> iced::Result { /// Hello::run(Settings::default()) @@ -78,7 +80,7 @@ use crate::{Color, Command, Element, Executor, Settings, Subscription}; /// String::from("A cool application") /// } /// -/// fn update(&mut self, _message: Self::Message) -> Command { +/// fn update(&mut self, _message: Self::Message, _clipboard: &mut Clipboard) -> Command { /// Command::none() /// } /// @@ -127,7 +129,11 @@ pub trait Application: Sized { /// this method. /// /// Any [`Command`] returned will be executed immediately in the background. - fn update(&mut self, message: Self::Message) -> Command; + fn update( + &mut self, + message: Self::Message, + clipboard: &mut Clipboard, + ) -> Command; /// Returns the event [`Subscription`] for the current state of the /// application. @@ -228,9 +234,14 @@ where { type Renderer = crate::renderer::Renderer; type Message = A::Message; - - fn update(&mut self, message: Self::Message) -> Command { - self.0.update(message) + type Clipboard = iced_winit::Clipboard; + + fn update( + &mut self, + message: Self::Message, + clipboard: &mut iced_winit::Clipboard, + ) -> Command { + self.0.update(message, clipboard) } fn view(&mut self) -> Element<'_, Self::Message> { -- cgit From 7da3fb1b2225732c87aebb13a067fbdb30b0cf2d Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 11 Mar 2021 03:49:45 +0100 Subject: Implement stub `Clipboard` in `iced_web` We need to figure out browser permissions and use of unstable `web-sys` APIs --- src/application.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/application.rs') diff --git a/src/application.rs b/src/application.rs index 162fde84..4c6d5b7f 100644 --- a/src/application.rs +++ b/src/application.rs @@ -305,8 +305,12 @@ where self.0.title() } - fn update(&mut self, message: Self::Message) -> Command { - self.0.update(message) + fn update( + &mut self, + message: Self::Message, + clipboard: &mut Clipboard, + ) -> Command { + self.0.update(message, clipboard) } fn subscription(&self) -> Subscription { -- cgit