pub struct WebView<Engine, Message>where
Engine: Engine,{ /* private fields */ }Expand description
The Advanced WebView widget that creates and shows webview(s).
Important: You must drive the webview with a periodic
Action::Update / Action::UpdateAll subscription (e.g. via
iced::time::every). Without it the webview will never render and the
screen stays blank.
fn subscription(&self) -> iced::Subscription<Message> {
iced::time::every(std::time::Duration::from_millis(16))
.map(|_| Message::WebView(Action::UpdateAll))
}Implementations§
Source§impl<Engine: Engine + Default, Message: Send + Clone + 'static> WebView<Engine, Message>
impl<Engine: Engine + Default, Message: Send + Clone + 'static> WebView<Engine, Message>
Sourcepub fn set_scale_factor(&mut self, scale: f32)
pub fn set_scale_factor(&mut self, scale: f32)
Set the display scale factor for HiDPI rendering.
Sourcepub fn on_create_view(
self,
on_create_view: impl Fn(usize) -> Message + 'static,
) -> Self
pub fn on_create_view( self, on_create_view: impl Fn(usize) -> Message + 'static, ) -> Self
Subscribe to create view events
Sourcepub fn on_close_view(
self,
on_close_view: impl Fn(usize) -> Message + 'static,
) -> Self
pub fn on_close_view( self, on_close_view: impl Fn(usize) -> Message + 'static, ) -> Self
Subscribe to close view events
Sourcepub fn on_url_change(
self,
on_url_change: impl Fn(ViewId, String) -> Message + 'static,
) -> Self
pub fn on_url_change( self, on_url_change: impl Fn(ViewId, String) -> Message + 'static, ) -> Self
Subscribe to url change events
Sourcepub fn on_title_change(
self,
on_title_change: impl Fn(ViewId, String) -> Message + 'static,
) -> Self
pub fn on_title_change( self, on_title_change: impl Fn(ViewId, String) -> Message + 'static, ) -> Self
Subscribe to title change events
Sourcepub fn on_copy(self, on_copy: impl Fn(String) -> Message + 'static) -> Self
pub fn on_copy(self, on_copy: impl Fn(String) -> Message + 'static) -> Self
Subscribe to copy events (text selection copied via Ctrl+C / Cmd+C)
Sourcepub fn on_action(
self,
mapper: impl Fn(Action) -> Message + Send + Sync + 'static,
) -> Self
pub fn on_action( self, mapper: impl Fn(Action) -> Message + Send + Sync + 'static, ) -> Self
Provide a mapper from Action to Message so the webview can spawn
async tasks that route back through the iced update loop. Required
for litehtml and blitz engines — without it, URL navigation and image
loading will not work.
Sourcepub fn with_initial_size(self, size: Size<u32>) -> Self
pub fn with_initial_size(self, size: Size<u32>) -> Self
Set the initial viewport size used before the first resize event. Defaults to 1920x1080.
Trait Implementations§
Auto Trait Implementations§
impl<Engine, Message> Freeze for WebView<Engine, Message>where
Engine: Freeze,
impl<Engine, Message> !RefUnwindSafe for WebView<Engine, Message>
impl<Engine, Message> !Send for WebView<Engine, Message>
impl<Engine, Message> !Sync for WebView<Engine, Message>
impl<Engine, Message> Unpin for WebView<Engine, Message>where
Engine: Unpin,
impl<Engine, Message> UnsafeUnpin for WebView<Engine, Message>where
Engine: UnsafeUnpin,
impl<Engine, Message> !UnwindSafe for WebView<Engine, Message>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().