summaryrefslogtreecommitdiffstats
path: root/runtime/src/clipboard.rs
diff options
context:
space:
mode:
authorLibravatar Mattias Eriksson <snaggen@mayam.com>2024-02-07 17:25:40 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-02-13 03:14:30 +0100
commit4155edab8d123b767ddad67e24ca2d4c50f31ece (patch)
tree30c81bc419920dd2e425f05caf160377b85ca961 /runtime/src/clipboard.rs
parent7615b2240c360fea21ef041bfd5b1deb73fc03d1 (diff)
downloadiced-4155edab8d123b767ddad67e24ca2d4c50f31ece.tar.gz
iced-4155edab8d123b767ddad67e24ca2d4c50f31ece.tar.bz2
iced-4155edab8d123b767ddad67e24ca2d4c50f31ece.zip
Add support for primary clipboard
Diffstat (limited to 'runtime/src/clipboard.rs')
-rw-r--r--runtime/src/clipboard.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/runtime/src/clipboard.rs b/runtime/src/clipboard.rs
index bc450912..49044a0f 100644
--- a/runtime/src/clipboard.rs
+++ b/runtime/src/clipboard.rs
@@ -51,3 +51,17 @@ pub fn read<Message>(
pub fn write<Message>(contents: String) -> Command<Message> {
Command::single(command::Action::Clipboard(Action::Write(contents)))
}
+
+/// Read the current contents of primary.
+pub fn read_primary<Message>(
+ f: impl Fn(Option<String>) -> Message + 'static,
+) -> Command<Message> {
+ Command::single(command::Action::ClipboardPrimary(Action::Read(Box::new(
+ f,
+ ))))
+}
+
+/// Write the given contents to primary.
+pub fn write_primary<Message>(contents: String) -> Command<Message> {
+ Command::single(command::Action::ClipboardPrimary(Action::Write(contents)))
+}