Update window_clipboard
to 0.2
This commit is contained in:
parent
bbca5c4bde
commit
b22b0dd7ff
@ -136,7 +136,7 @@ async fn run_instance<A, E, C>(
|
||||
use glutin::event;
|
||||
use iced_winit::futures::stream::StreamExt;
|
||||
|
||||
let clipboard = Clipboard::new(context.window());
|
||||
let clipboard = Clipboard::connect(context.window());
|
||||
|
||||
let mut state = application::State::new(&application, context.window());
|
||||
let mut viewport_version = state.viewport_version();
|
||||
|
@ -1,6 +1,6 @@
|
||||
/// A buffer for short-term storage and transfer within and between
|
||||
/// applications.
|
||||
pub trait Clipboard {
|
||||
/// Returns the current content of the [`Clipboard`] as text.
|
||||
fn content(&self) -> Option<String>;
|
||||
/// Reads the current content of the [`Clipboard`] as text.
|
||||
fn read(&self) -> Option<String>;
|
||||
}
|
||||
|
@ -509,7 +509,7 @@ where
|
||||
Some(content) => content,
|
||||
None => {
|
||||
let content: String = clipboard
|
||||
.content()
|
||||
.read()
|
||||
.unwrap_or(String::new())
|
||||
.chars()
|
||||
.filter(|c| !c.is_control())
|
||||
|
@ -15,7 +15,7 @@ debug = ["iced_native/debug"]
|
||||
|
||||
[dependencies]
|
||||
winit = "0.24"
|
||||
window_clipboard = "0.1"
|
||||
window_clipboard = "0.2"
|
||||
log = "0.4"
|
||||
thiserror = "1.0"
|
||||
|
||||
|
@ -194,7 +194,7 @@ async fn run_instance<A, E, C>(
|
||||
use winit::event;
|
||||
|
||||
let surface = compositor.create_surface(&window);
|
||||
let clipboard = Clipboard::new(&window);
|
||||
let clipboard = Clipboard::connect(&window);
|
||||
|
||||
let mut state = State::new(&application, &window);
|
||||
let mut viewport_version = state.viewport_version();
|
||||
|
@ -5,13 +5,15 @@ pub struct Clipboard(window_clipboard::Clipboard);
|
||||
|
||||
impl Clipboard {
|
||||
/// Creates a new [`Clipboard`] for the given window.
|
||||
pub fn new(window: &winit::window::Window) -> Option<Clipboard> {
|
||||
window_clipboard::Clipboard::new(window).map(Clipboard).ok()
|
||||
pub fn connect(window: &winit::window::Window) -> Option<Clipboard> {
|
||||
window_clipboard::Clipboard::connect(window)
|
||||
.map(Clipboard)
|
||||
.ok()
|
||||
}
|
||||
}
|
||||
|
||||
impl iced_native::Clipboard for Clipboard {
|
||||
fn content(&self) -> Option<String> {
|
||||
fn read(&self) -> Option<String> {
|
||||
self.0.read().ok()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user