diff options
author | 2021-03-12 02:54:13 +0100 | |
---|---|---|
committer | 2021-03-12 02:54:13 +0100 | |
commit | c1f70f1e9252b1971c17cd385273460c669fac26 (patch) | |
tree | 602a967f936bc9887f281143c63ec3d49b35fcc1 /winit/src/clipboard.rs | |
parent | 7eb512774862d44772c43f9843f586bfcfa2aa89 (diff) | |
parent | 7da3fb1b2225732c87aebb13a067fbdb30b0cf2d (diff) | |
download | iced-c1f70f1e9252b1971c17cd385273460c669fac26.tar.gz iced-c1f70f1e9252b1971c17cd385273460c669fac26.tar.bz2 iced-c1f70f1e9252b1971c17cd385273460c669fac26.zip |
Merge pull request #773 from hecrj/feature/clipboard-access-in-update
Clipboard access in `Application::update`
Diffstat (limited to 'winit/src/clipboard.rs')
-rw-r--r-- | winit/src/clipboard.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/winit/src/clipboard.rs b/winit/src/clipboard.rs index 15dc989f..ca25c065 100644 --- a/winit/src/clipboard.rs +++ b/winit/src/clipboard.rs @@ -20,17 +20,17 @@ impl Clipboard { Clipboard { state } } -} -impl iced_native::Clipboard for Clipboard { - fn read(&self) -> Option<String> { + /// Reads the current content of the [`Clipboard`] as text. + pub fn read(&self) -> Option<String> { match &self.state { State::Connected(clipboard) => clipboard.read().ok(), State::Unavailable => None, } } - fn write(&mut self, contents: String) { + /// Writes the given text contents to the [`Clipboard`]. + pub fn write(&mut self, contents: String) { match &mut self.state { State::Connected(clipboard) => match clipboard.write(contents) { Ok(()) => {} @@ -42,3 +42,13 @@ impl iced_native::Clipboard for Clipboard { } } } + +impl iced_native::Clipboard for Clipboard { + fn read(&self) -> Option<String> { + self.read() + } + + fn write(&mut self, contents: String) { + self.write(contents) + } +} |