Implement and expose read and write helpers for clipboard
This commit is contained in:
parent
6887afdb2c
commit
7a335a0408
4 changed files with 22 additions and 1 deletions
|
|
@ -16,10 +16,13 @@ pub use iced_native::*;
|
||||||
|
|
||||||
pub mod application;
|
pub mod application;
|
||||||
|
|
||||||
|
pub use iced_winit::clipboard;
|
||||||
pub use iced_winit::settings;
|
pub use iced_winit::settings;
|
||||||
pub use iced_winit::{Clipboard, Error, Mode};
|
pub use iced_winit::{Error, Mode};
|
||||||
|
|
||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
pub use application::Application;
|
pub use application::Application;
|
||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
|
pub use clipboard::Clipboard;
|
||||||
|
#[doc(no_inline)]
|
||||||
pub use settings::Settings;
|
pub use settings::Settings;
|
||||||
|
|
|
||||||
3
src/clipboard.rs
Normal file
3
src/clipboard.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
//! Access the clipboard.
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
pub use crate::runtime::clipboard::{read, write};
|
||||||
|
|
@ -183,6 +183,7 @@ mod error;
|
||||||
mod result;
|
mod result;
|
||||||
mod sandbox;
|
mod sandbox;
|
||||||
|
|
||||||
|
pub mod clipboard;
|
||||||
pub mod executor;
|
pub mod executor;
|
||||||
pub mod keyboard;
|
pub mod keyboard;
|
||||||
pub mod mouse;
|
pub mod mouse;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
//! Access the clipboard.
|
//! Access the clipboard.
|
||||||
pub use iced_native::clipboard::Action;
|
pub use iced_native::clipboard::Action;
|
||||||
|
|
||||||
|
use crate::command::{self, Command};
|
||||||
|
|
||||||
/// A buffer for short-term storage and transfer within and between
|
/// A buffer for short-term storage and transfer within and between
|
||||||
/// applications.
|
/// applications.
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
|
|
@ -55,3 +57,15 @@ impl iced_native::Clipboard for Clipboard {
|
||||||
self.write(contents)
|
self.write(contents)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Read the current contents of the clipboard.
|
||||||
|
pub fn read<Message>(
|
||||||
|
f: impl Fn(Option<String>) -> Message + 'static,
|
||||||
|
) -> Command<Message> {
|
||||||
|
Command::Single(command::Action::Clipboard(Action::Read(Box::new(f))))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Write the given contents to the clipboard.
|
||||||
|
pub fn write<Message>(contents: String) -> Command<Message> {
|
||||||
|
Command::Single(command::Action::Clipboard(Action::Write(contents)))
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue