Skip to content

Commit cf4c4f8

Browse files
committed
core: Add clipboard_content getter
1 parent c2b768c commit cf4c4f8

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

core/src/backend/input.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ pub trait InputBackend: Downcast {
1717
/// Changes the mouse cursor image.
1818
fn set_mouse_cursor(&mut self, cursor: MouseCursor);
1919

20+
/// Get the clipboard content
21+
fn clipboard_content(&mut self) -> String;
22+
2023
/// Set the clipboard to the given content
2124
fn set_clipboard_content(&mut self, content: String);
2225
}
@@ -54,6 +57,10 @@ impl InputBackend for NullInputBackend {
5457

5558
fn set_mouse_cursor(&mut self, _cursor: MouseCursor) {}
5659

60+
fn clipboard_content(&mut self) -> String {
61+
"".to_string()
62+
}
63+
5764
fn set_clipboard_content(&mut self, _content: String) {}
5865
}
5966

desktop/src/input.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ impl InputBackend for WinitInputBackend {
212212
self.window.set_cursor_icon(icon);
213213
}
214214

215+
fn clipboard_content(&mut self) -> String {
216+
self.clipboard
217+
.get_contents()
218+
.unwrap_or_else(|_| "".to_string())
219+
}
220+
215221
fn set_clipboard_content(&mut self, content: String) {
216222
self.clipboard.set_contents(content).unwrap();
217223
}

web/src/input.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ impl InputBackend for WebInputBackend {
195195
self.update_mouse_cursor();
196196
}
197197

198+
fn clipboard_content(&mut self) -> String {
199+
log::warn!("get clipboard not implemented");
200+
"".to_string()
201+
}
202+
198203
fn set_clipboard_content(&mut self, _content: String) {
199204
log::warn!("set clipboard not implemented");
200205
}

0 commit comments

Comments
 (0)