diff options
Diffstat (limited to 'winit/src/clipboard.rs')
-rw-r--r-- | winit/src/clipboard.rs | 17 |
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))) +} |