Struct WebviewNavigation

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

Contains details about a navigation action.

Implementations§

Source§

impl WebviewNavigation

Source

pub fn is_new_window(&self) -> bool

Checks whether the navigation requests a new window to be created.

Examples found in repository?
examples\navigation.rs (line 22)
13fn main() {
14    let (_cc, app) = App::new(AppOptions::new("Navigation"));
15
16    let w = Webview::new(&Preferences::new(&app)).unwrap();
17
18    w.set_size(1152, 648);
19    w.set_url("https://saucer.app");
20
21    w.on::<NavigateEvent>(Box::new(move |w, nav| {
22        if nav.is_new_window() && nav.is_user_initiated() {
23            // The event handler is fired on the event thread, so creating a window without posting is fine.
24            let app = w.app();
25            let new_window = Webview::new(&Preferences::new(&app)).unwrap();
26            new_window.set_url(nav.url());
27            new_window.set_size(1152, 648);
28            new_window.show();
29            // The app internally maintains a list of webviews, so dropping `new_window` won't destroy it.
30        }
31        true
32    }));
33
34    w.show();
35
36    app.run();
37}
Source

pub fn is_redirection(&self) -> bool

Checks whether the navigation is initiated by a redirection.

Source

pub fn is_user_initiated(&self) -> bool

Checks whether the navigation is initiated by user actions.

Examples found in repository?
examples\navigation.rs (line 22)
13fn main() {
14    let (_cc, app) = App::new(AppOptions::new("Navigation"));
15
16    let w = Webview::new(&Preferences::new(&app)).unwrap();
17
18    w.set_size(1152, 648);
19    w.set_url("https://saucer.app");
20
21    w.on::<NavigateEvent>(Box::new(move |w, nav| {
22        if nav.is_new_window() && nav.is_user_initiated() {
23            // The event handler is fired on the event thread, so creating a window without posting is fine.
24            let app = w.app();
25            let new_window = Webview::new(&Preferences::new(&app)).unwrap();
26            new_window.set_url(nav.url());
27            new_window.set_size(1152, 648);
28            new_window.show();
29            // The app internally maintains a list of webviews, so dropping `new_window` won't destroy it.
30        }
31        true
32    }));
33
34    w.show();
35
36    app.run();
37}
Source

pub fn url(&self) -> String

Gets the URL that’s about to navigate to.

Examples found in repository?
examples\navigation.rs (line 26)
13fn main() {
14    let (_cc, app) = App::new(AppOptions::new("Navigation"));
15
16    let w = Webview::new(&Preferences::new(&app)).unwrap();
17
18    w.set_size(1152, 648);
19    w.set_url("https://saucer.app");
20
21    w.on::<NavigateEvent>(Box::new(move |w, nav| {
22        if nav.is_new_window() && nav.is_user_initiated() {
23            // The event handler is fired on the event thread, so creating a window without posting is fine.
24            let app = w.app();
25            let new_window = Webview::new(&Preferences::new(&app)).unwrap();
26            new_window.set_url(nav.url());
27            new_window.set_size(1152, 648);
28            new_window.show();
29            // The app internally maintains a list of webviews, so dropping `new_window` won't destroy it.
30        }
31        true
32    }));
33
34    w.show();
35
36    app.run();
37}

Trait Implementations§

Source§

impl Drop for WebviewNavigation

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for WebviewNavigation

Source§

impl Sync for WebviewNavigation

Auto Trait Implementations§

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.