diff options
author | 2021-03-11 03:49:45 +0100 | |
---|---|---|
committer | 2021-03-11 03:52:41 +0100 | |
commit | 7da3fb1b2225732c87aebb13a067fbdb30b0cf2d (patch) | |
tree | 602a967f936bc9887f281143c63ec3d49b35fcc1 /web/src/lib.rs | |
parent | a365998264420b1dac26a0de8e50ad4a33900885 (diff) | |
download | iced-7da3fb1b2225732c87aebb13a067fbdb30b0cf2d.tar.gz iced-7da3fb1b2225732c87aebb13a067fbdb30b0cf2d.tar.bz2 iced-7da3fb1b2225732c87aebb13a067fbdb30b0cf2d.zip |
Implement stub `Clipboard` in `iced_web`
We need to figure out browser permissions and use of unstable `web-sys`
APIs
Diffstat (limited to 'web/src/lib.rs')
-rw-r--r-- | web/src/lib.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/web/src/lib.rs b/web/src/lib.rs index 58f6591d..4c65dfa3 100644 --- a/web/src/lib.rs +++ b/web/src/lib.rs @@ -59,6 +59,7 @@ use dodrio::bumpalo; use std::{cell::RefCell, rc::Rc}; mod bus; +mod clipboard; mod element; mod hasher; @@ -67,6 +68,7 @@ pub mod subscription; pub mod widget; pub use bus::Bus; +pub use clipboard::Clipboard; pub use css::Css; pub use dodrio; pub use element::Element; @@ -126,7 +128,11 @@ pub trait Application { /// this method. /// /// Any [`Command`] returned will be executed immediately in the background. - fn update(&mut self, message: Self::Message) -> Command<Self::Message>; + fn update( + &mut self, + message: Self::Message, + clipboard: &mut Clipboard, + ) -> Command<Self::Message>; /// Returns the widgets to display in the [`Application`]. /// @@ -156,6 +162,8 @@ pub trait Application { let document = window.document().unwrap(); let body = document.body().unwrap(); + let mut clipboard = Clipboard::new(); + let (sender, receiver) = iced_futures::futures::channel::mpsc::unbounded(); @@ -182,7 +190,8 @@ pub trait Application { let event_loop = receiver.for_each(move |message| { let (command, subscription) = runtime.enter(|| { - let command = application.borrow_mut().update(message); + let command = + application.borrow_mut().update(message, &mut clipboard); let subscription = application.borrow().subscription(); (command, subscription) |