summaryrefslogtreecommitdiffstats
path: root/src/application.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2021-03-12 02:54:13 +0100
committerLibravatar GitHub <noreply@github.com>2021-03-12 02:54:13 +0100
commitc1f70f1e9252b1971c17cd385273460c669fac26 (patch)
tree602a967f936bc9887f281143c63ec3d49b35fcc1 /src/application.rs
parent7eb512774862d44772c43f9843f586bfcfa2aa89 (diff)
parent7da3fb1b2225732c87aebb13a067fbdb30b0cf2d (diff)
downloadiced-c1f70f1e9252b1971c17cd385273460c669fac26.tar.gz
iced-c1f70f1e9252b1971c17cd385273460c669fac26.tar.bz2
iced-c1f70f1e9252b1971c17cd385273460c669fac26.zip
Merge pull request #773 from hecrj/feature/clipboard-access-in-update
Clipboard access in `Application::update`
Diffstat (limited to 'src/application.rs')
-rw-r--r--src/application.rs33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/application.rs b/src/application.rs
index 3b690a7c..4c6d5b7f 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> {
@@ -294,8 +305,12 @@ where
self.0.title()
}
- fn update(&mut self, message: Self::Message) -> Command<Self::Message> {
- self.0.update(message)
+ fn update(
+ &mut self,
+ message: Self::Message,
+ clipboard: &mut Clipboard,
+ ) -> Command<Self::Message> {
+ self.0.update(message, clipboard)
}
fn subscription(&self) -> Subscription<Self::Message> {