summaryrefslogtreecommitdiffstats
path: root/winit
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-09-02 15:12:55 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-09-02 15:12:55 +0700
commit7a335a0408b3ee426949a1936255666bc3383ea9 (patch)
tree01894e388d1629c181446c6f41b2204906726841 /winit
parent6887afdb2c71429fa032d68f2ee3a4a075ecca1d (diff)
downloadiced-7a335a0408b3ee426949a1936255666bc3383ea9.tar.gz
iced-7a335a0408b3ee426949a1936255666bc3383ea9.tar.bz2
iced-7a335a0408b3ee426949a1936255666bc3383ea9.zip
Implement and expose `read` and `write` helpers for `clipboard`
Diffstat (limited to 'winit')
-rw-r--r--winit/src/clipboard.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/winit/src/clipboard.rs b/winit/src/clipboard.rs
index 9d0663fa..05d991ff 100644
--- a/winit/src/clipboard.rs
+++ b/winit/src/clipboard.rs
@@ -1,6 +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)]
@@ -55,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)))
+}