Implement stub `Clipboard` in `iced_web`
We need to figure out browser permissions and use of unstable `web-sys` APIs
This commit is contained in:
parent
a365998264
commit
7da3fb1b22
|
@ -305,8 +305,12 @@ where
|
||||||
self.0.title()
|
self.0.title()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, message: Self::Message) -> Command<Self::Message> {
|
fn update(
|
||||||
self.0.update(message)
|
&mut self,
|
||||||
|
message: Self::Message,
|
||||||
|
clipboard: &mut Clipboard,
|
||||||
|
) -> Command<Self::Message> {
|
||||||
|
self.0.update(message, clipboard)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn subscription(&self) -> Subscription<Self::Message> {
|
fn subscription(&self) -> Subscription<Self::Message> {
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
/// A buffer for short-term storage and transfer within and between
|
||||||
|
/// applications.
|
||||||
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
pub struct Clipboard;
|
||||||
|
|
||||||
|
impl Clipboard {
|
||||||
|
/// Creates a new [`Clipboard`].
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reads the current content of the [`Clipboard`] as text.
|
||||||
|
pub fn read(&self) -> Option<String> {
|
||||||
|
unimplemented! {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Writes the given text contents to the [`Clipboard`].
|
||||||
|
pub fn write(&mut self, _contents: String) {
|
||||||
|
unimplemented! {}
|
||||||
|
}
|
||||||
|
}
|
|
@ -59,6 +59,7 @@ use dodrio::bumpalo;
|
||||||
use std::{cell::RefCell, rc::Rc};
|
use std::{cell::RefCell, rc::Rc};
|
||||||
|
|
||||||
mod bus;
|
mod bus;
|
||||||
|
mod clipboard;
|
||||||
mod element;
|
mod element;
|
||||||
mod hasher;
|
mod hasher;
|
||||||
|
|
||||||
|
@ -67,6 +68,7 @@ pub mod subscription;
|
||||||
pub mod widget;
|
pub mod widget;
|
||||||
|
|
||||||
pub use bus::Bus;
|
pub use bus::Bus;
|
||||||
|
pub use clipboard::Clipboard;
|
||||||
pub use css::Css;
|
pub use css::Css;
|
||||||
pub use dodrio;
|
pub use dodrio;
|
||||||
pub use element::Element;
|
pub use element::Element;
|
||||||
|
@ -126,7 +128,11 @@ pub trait Application {
|
||||||
/// this method.
|
/// this method.
|
||||||
///
|
///
|
||||||
/// Any [`Command`] returned will be executed immediately in the background.
|
/// 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`].
|
/// Returns the widgets to display in the [`Application`].
|
||||||
///
|
///
|
||||||
|
@ -156,6 +162,8 @@ pub trait Application {
|
||||||
let document = window.document().unwrap();
|
let document = window.document().unwrap();
|
||||||
let body = document.body().unwrap();
|
let body = document.body().unwrap();
|
||||||
|
|
||||||
|
let mut clipboard = Clipboard::new();
|
||||||
|
|
||||||
let (sender, receiver) =
|
let (sender, receiver) =
|
||||||
iced_futures::futures::channel::mpsc::unbounded();
|
iced_futures::futures::channel::mpsc::unbounded();
|
||||||
|
|
||||||
|
@ -182,7 +190,8 @@ pub trait Application {
|
||||||
|
|
||||||
let event_loop = receiver.for_each(move |message| {
|
let event_loop = receiver.for_each(move |message| {
|
||||||
let (command, subscription) = runtime.enter(|| {
|
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();
|
let subscription = application.borrow().subscription();
|
||||||
|
|
||||||
(command, subscription)
|
(command, subscription)
|
||||||
|
|
Loading…
Reference in New Issue