WebView

Struct WebView 

Source
pub struct WebView { /* private fields */ }
Expand description

A webview based on wry WebView.

[experimental]

Implementations§

Source§

impl WebView

Source

pub fn new(webview: WebView, _: &mut Window, cx: &mut App) -> Self

Create a new WebView from a wry WebView.

Source

pub fn show(&mut self)

Show the webview.

Source

pub fn hide(&mut self)

Hide the webview.

Source

pub fn visible(&self) -> bool

Get whether the webview is visible.

Source

pub fn bounds(&self) -> Bounds<Pixels>

Get the current bounds of the webview.

Source

pub fn back(&mut self) -> Result<()>

Go back in the webview history.

Source

pub fn load_url(&mut self, url: &str)

Load a URL in the webview.

Source

pub fn raw(&self) -> &WebView

Get the raw wry webview.

Methods from Deref<Target = WebView>§

Source

pub fn id(&self) -> &str

Returns the id of this webview.

Source

pub fn url(&self) -> Result<String, Error>

Get the current url of the webview

Source

pub fn evaluate_script(&self, js: &str) -> Result<(), Error>

Evaluate and run javascript code.

Source

pub fn evaluate_script_with_callback( &self, js: &str, callback: impl Fn(String) + Send + 'static, ) -> Result<(), Error>

Evaluate and run javascript code with callback function. The evaluation result will be serialized into a JSON string and passed to the callback function.

Exception is ignored because of the limitation on windows. You can catch it yourself and return as string as a workaround.

  • ** Android:** Not implemented yet.
Source

pub fn print(&self) -> Result<(), Error>

Launch print modal for the webview content.

Source

pub fn cookies_for_url(&self, url: &str) -> Result<Vec<Cookie<'static>>, Error>

Get a list of cookies for specific url.

Source

pub fn cookies(&self) -> Result<Vec<Cookie<'static>>, Error>

Get the list of cookies.

§Platform-specific
  • Android: Unsupported, always returns an empty Vec.

Set a cookie for the webview.

§Platform-specific
  • Android: Not supported.

Delete a cookie for the webview.

§Platform-specific
  • Android: Not supported.
Source

pub fn open_devtools(&self)

Open the web inspector which is usually called dev tool.

§Platform-specific
  • Android / iOS: Not supported.
Source

pub fn close_devtools(&self)

Close the web inspector which is usually called dev tool.

§Platform-specific
  • Windows / Android / iOS: Not supported.
Source

pub fn is_devtools_open(&self) -> bool

Gets the devtool window’s current visibility state.

§Platform-specific
  • Windows / Android / iOS: Not supported.
Source

pub fn zoom(&self, scale_factor: f64) -> Result<(), Error>

Set the webview zoom level

§Platform-specific:
  • Android: Not supported.
  • macOS: available on macOS 11+ only.
  • iOS: available on iOS 14+ only.
Source

pub fn set_background_color( &self, background_color: (u8, u8, u8, u8), ) -> Result<(), Error>

Specify the webview background color.

The color uses the RGBA format.

§Platfrom-specific:
  • macOS: Not implemented.
  • Windows:
    • On Windows 7, transparency is not supported and the alpha value will be ignored.
    • On Windows higher than 7: translucent colors are not supported so any alpha value other than 0 will be replaced by 255
Source

pub fn load_url(&self, url: &str) -> Result<(), Error>

Navigate to the specified url

Source

pub fn reload(&self) -> Result<(), Error>

Reloads the current page.

Source

pub fn load_url_with_headers( &self, url: &str, headers: HeaderMap, ) -> Result<(), Error>

Navigate to the specified url using the specified headers

Source

pub fn load_html(&self, html: &str) -> Result<(), Error>

Load html content into the webview

Source

pub fn clear_all_browsing_data(&self) -> Result<(), Error>

Clear all browsing data

Source

pub fn bounds(&self) -> Result<Rect, Error>

Source

pub fn set_bounds(&self, bounds: Rect) -> Result<(), Error>

Set the webview bounds.

This is only effective if the webview was created as a child or created using [WebViewBuilderExtUnix::new_gtk] with gtk::Fixed.

Source

pub fn set_visible(&self, visible: bool) -> Result<(), Error>

Shows or hides the webview.

Source

pub fn focus(&self) -> Result<(), Error>

Try moving focus to the webview.

Source

pub fn focus_parent(&self) -> Result<(), Error>

Try moving focus away from the webview back to the parent window.

§Platform-specific:
  • Android: Not implemented.

Trait Implementations§

Source§

impl Deref for WebView

Source§

type Target = WebView

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Drop for WebView

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Focusable for WebView

Source§

fn focus_handle(&self, _cx: &App) -> FocusHandle

Returns the focus handle associated with this view.
Source§

impl Render for WebView

Source§

fn render( &mut self, window: &mut Window, cx: &mut Context<'_, Self>, ) -> impl IntoElement

Render this view into an element tree.
Source§

impl EventEmitter<DismissEvent> for WebView

Auto Trait Implementations§

§

impl Freeze for WebView

§

impl !RefUnwindSafe for WebView

§

impl !Send for WebView

§

impl !Sync for WebView

§

impl Unpin for WebView

§

impl !UnwindSafe for WebView

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<M> ManagedView for M