summaryrefslogtreecommitdiffstats
path: root/winit/src/clipboard.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2021-09-13 11:49:06 +0700
committerLibravatar GitHub <noreply@github.com>2021-09-13 11:49:06 +0700
commit93fec8d273ef8305e1c2456abe0c8ecd7a9d9407 (patch)
treec0c2445703133293b13657ab4f9c1c936e9cd688 /winit/src/clipboard.rs
parent589f68df0f647d93f2b9dd7bf29cfacb0201351c (diff)
parent01b945b9814b9dc546e783a6dab66e4f7fe49786 (diff)
downloadiced-93fec8d273ef8305e1c2456abe0c8ecd7a9d9407.tar.gz
iced-93fec8d273ef8305e1c2456abe0c8ecd7a9d9407.tar.bz2
iced-93fec8d273ef8305e1c2456abe0c8ecd7a9d9407.zip
Merge pull request #1019 from hecrj/command-actions
Platform-specific `Command` implementations
Diffstat (limited to 'winit/src/clipboard.rs')
-rw-r--r--winit/src/clipboard.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/winit/src/clipboard.rs b/winit/src/clipboard.rs
index ca25c065..1b92b28d 100644
--- a/winit/src/clipboard.rs
+++ b/winit/src/clipboard.rs
@@ -1,3 +1,8 @@
+//! Access the clipboard.
+pub use iced_native::clipboard::Action;
+
+use crate::command::{self, Command};
+
/// A buffer for short-term storage and transfer within and between
/// applications.
#[allow(missing_debug_implementations)]
@@ -52,3 +57,15 @@ impl iced_native::Clipboard for Clipboard {
self.write(contents)
}
}
+
+/// Read the current contents of the clipboard.
+pub fn read<Message>(
+ f: impl Fn(Option<String>) -> Message + 'static,
+) -> Command<Message> {
+ Command::single(command::Action::Clipboard(Action::Read(Box::new(f))))
+}
+
+/// Write the given contents to the clipboard.
+pub fn write<Message>(contents: String) -> Command<Message> {
+ Command::single(command::Action::Clipboard(Action::Write(contents)))
+}