summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-03-11 03:38:20 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-03-11 03:38:20 +0100
commitae517b9fa033ba75df5fc6ce766698fab22504fa (patch)
tree52301933e60b12eb58885ef6671869ada84dcaca /src
parent7eb512774862d44772c43f9843f586bfcfa2aa89 (diff)
downloadiced-ae517b9fa033ba75df5fc6ce766698fab22504fa.tar.gz
iced-ae517b9fa033ba75df5fc6ce766698fab22504fa.tar.bz2
iced-ae517b9fa033ba75df5fc6ce766698fab22504fa.zip
Add `clipboard` argument to `Application::update`
Diffstat (limited to 'src')
-rw-r--r--src/application.rs25
-rw-r--r--src/lib.rs5
-rw-r--r--src/sandbox.rs9
3 files changed, 28 insertions, 11 deletions
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<Self::Message> {
+/// fn update(&mut self, _message: Self::Message, _clipboard: &mut Clipboard) -> Command<Self::Message> {
/// 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<Self::Message>;
+ fn update(
+ &mut self,
+ message: Self::Message,
+ clipboard: &mut Clipboard,
+ ) -> Command<Self::Message>;
/// 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::Message> {
- self.0.update(message)
+ type Clipboard = iced_winit::Clipboard;
+
+ fn update(
+ &mut self,
+ message: Self::Message,
+ clipboard: &mut iced_winit::Clipboard,
+ ) -> Command<Self::Message> {
+ self.0.update(message, clipboard)
}
fn view(&mut self) -> Element<'_, Self::Message> {
diff --git a/src/lib.rs b/src/lib.rs
index dedcac7a..812a50c1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -245,6 +245,7 @@ pub use sandbox::Sandbox;
pub use settings::Settings;
pub use runtime::{
- futures, Align, Background, Color, Command, Font, HorizontalAlignment,
- Length, Point, Rectangle, Size, Subscription, Vector, VerticalAlignment,
+ futures, Align, Background, Clipboard, Color, Command, Font,
+ HorizontalAlignment, Length, Point, Rectangle, Size, Subscription, Vector,
+ VerticalAlignment,
};
diff --git a/src/sandbox.rs b/src/sandbox.rs
index b53fa1f2..9dd17b7e 100644
--- a/src/sandbox.rs
+++ b/src/sandbox.rs
@@ -1,5 +1,6 @@
use crate::{
- Application, Color, Command, Element, Error, Settings, Subscription,
+ Application, Clipboard, Color, Command, Element, Error, Settings,
+ Subscription,
};
/// A sandboxed [`Application`].
@@ -161,7 +162,11 @@ where
T::title(self)
}
- fn update(&mut self, message: T::Message) -> Command<T::Message> {
+ fn update(
+ &mut self,
+ message: T::Message,
+ _clipboard: &mut Clipboard,
+ ) -> Command<T::Message> {
T::update(self, message);
Command::none()