diff options
author | 2021-09-13 11:49:06 +0700 | |
---|---|---|
committer | 2021-09-13 11:49:06 +0700 | |
commit | 93fec8d273ef8305e1c2456abe0c8ecd7a9d9407 (patch) | |
tree | c0c2445703133293b13657ab4f9c1c936e9cd688 /winit/src/clipboard.rs | |
parent | 589f68df0f647d93f2b9dd7bf29cfacb0201351c (diff) | |
parent | 01b945b9814b9dc546e783a6dab66e4f7fe49786 (diff) | |
download | iced-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.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))) +} |