summaryrefslogtreecommitdiffstats
path: root/winit
diff options
context:
space:
mode:
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)))
+}