summaryrefslogtreecommitdiffstats
path: root/runtime/src/clipboard.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--runtime/src/clipboard.rs (renamed from native/src/clipboard.rs)15
1 files changed, 14 insertions, 1 deletions
diff --git a/native/src/clipboard.rs b/runtime/src/clipboard.rs
index e727c4a7..bc450912 100644
--- a/native/src/clipboard.rs
+++ b/runtime/src/clipboard.rs
@@ -1,5 +1,6 @@
//! Access the clipboard.
-use iced_futures::MaybeSend;
+use crate::command::{self, Command};
+use crate::futures::MaybeSend;
use std::fmt;
@@ -38,3 +39,15 @@ impl<T> fmt::Debug for Action<T> {
}
}
}
+
+/// 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)))
+}