pub struct WebView { /* private fields */ }Expand description
Embeds a native WebView pointing to a given URL as a regular element in your UI.
§Requirements
The WebViewPlugin must be registered in your LaunchConfig
for this component to work, otherwise it will panic:
launch(
LaunchConfig::new()
.with_plugin(WebViewPlugin::new())
.with_window(WindowConfig::new(app)),
);WebViews are not supported on every platform, see the crate-level docs for details.
§Example
fn app() -> impl IntoElement {
WebView::new("https://example.com").expanded()
}Implementations§
Source§impl WebView
impl WebView
pub fn new(url: impl Into<String>) -> Self
Sourcepub fn id(self, id: WebViewId) -> Self
pub fn id(self, id: WebViewId) -> Self
Set a custom WebViewId so the WebView can be referenced later, e.g. with
WebViewManager::close.
Sourcepub fn close_on_drop(self, close: bool) -> Self
pub fn close_on_drop(self, close: bool) -> Self
If you decide to not close the webview on drop you will need to manually close it with WebViewManager::close.
Sourcepub fn on_created(
self,
on_created: impl Fn(WebViewBuilder<'_>) -> WebViewBuilder<'_> + Send + 'static,
) -> Self
pub fn on_created( self, on_created: impl Fn(WebViewBuilder<'_>) -> WebViewBuilder<'_> + Send + 'static, ) -> Self
Customize the underlying [wry::WebViewBuilder] right before the WebView is built, for
example to set a custom user agent or inject initialization scripts.
Trait Implementations§
Source§impl ContainerExt for WebView
impl ContainerExt for WebView
§fn position(self, position: impl Into<Position>) -> Self
fn position(self, position: impl Into<Position>) -> Self
Set how the element is placed relative to its parent or the window. See [
Position].§fn padding(self, padding: impl Into<Gaps>) -> Self
fn padding(self, padding: impl Into<Gaps>) -> Self
Set the inner spacing between the element’s edges and its content. See [
Gaps].§fn margin(self, margin: impl Into<Gaps>) -> Self
fn margin(self, margin: impl Into<Gaps>) -> Self
Set the outer spacing between the element’s edges and its surroundings. See [
Gaps].§fn min_width(self, minimum_width: impl Into<Size>) -> Self
fn min_width(self, minimum_width: impl Into<Size>) -> Self
Set the minimum width the element can shrink to. See [
Size].§fn min_height(self, minimum_height: impl Into<Size>) -> Self
fn min_height(self, minimum_height: impl Into<Size>) -> Self
Set the minimum height the element can shrink to. See [
Size].§fn max_width(self, maximum_width: impl Into<Size>) -> Self
fn max_width(self, maximum_width: impl Into<Size>) -> Self
Set the maximum width the element can grow to. See [
Size].§fn max_height(self, maximum_height: impl Into<Size>) -> Self
fn max_height(self, maximum_height: impl Into<Size>) -> Self
Set the maximum height the element can grow to. See [
Size].§fn visible_width(self, visible_width: impl Into<VisibleSize>) -> Self
fn visible_width(self, visible_width: impl Into<VisibleSize>) -> Self
Set how much of the measured width is actually used in layout. See [
VisibleSize].§fn visible_height(self, visible_height: impl Into<VisibleSize>) -> Self
fn visible_height(self, visible_height: impl Into<VisibleSize>) -> Self
Set how much of the measured height is actually used in layout. See [
VisibleSize].Source§impl LayoutExt for WebView
impl LayoutExt for WebView
Source§fn get_layout(&mut self) -> &mut LayoutData
fn get_layout(&mut self) -> &mut LayoutData
Returns a mutable reference to the element’s layout data.
Auto Trait Implementations§
impl Freeze for WebView
impl !RefUnwindSafe for WebView
impl !Send for WebView
impl !Sync for WebView
impl Unpin for WebView
impl UnsafeUnpin for WebView
impl !UnwindSafe for WebView
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> ComponentKey for Twhere
T: Component,
impl<T> ComponentKey for Twhere
T: Component,
fn default_key(&self) -> DiffKey
§impl<T> ComponentProps for T
impl<T> ComponentProps for T
§impl<T> ContainerSizeExt for Twhere
T: ContainerExt,
impl<T> ContainerSizeExt for Twhere
T: ContainerExt,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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 more