summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--native/src/clipboard.rs3
-rw-r--r--winit/src/clipboard.rs7
2 files changed, 10 insertions, 0 deletions
diff --git a/native/src/clipboard.rs b/native/src/clipboard.rs
index 3eeb184d..fdb769da 100644
--- a/native/src/clipboard.rs
+++ b/native/src/clipboard.rs
@@ -3,4 +3,7 @@
pub trait Clipboard {
/// Reads the current content of the [`Clipboard`] as text.
fn read(&self) -> Option<String>;
+
+ /// Writes the given text contents to the [`Clipboard`].
+ fn write(&mut self, contents: String);
}
diff --git a/winit/src/clipboard.rs b/winit/src/clipboard.rs
index cce2b371..06e7c1a8 100644
--- a/winit/src/clipboard.rs
+++ b/winit/src/clipboard.rs
@@ -16,4 +16,11 @@ impl iced_native::Clipboard for Clipboard {
fn read(&self) -> Option<String> {
self.0.read().ok()
}
+
+ fn write(&mut self, contents: String) {
+ match self.0.write(contents) {
+ Ok(()) => {}
+ Err(error) => log::warn!("error writing to clipboard: {}", error),
+ }
+ }
}