pub struct WebviewNavigation { /* private fields */ }
Expand description
Contains details about a navigation action.
Implementations§
Sourcepub fn is_new_window(&self) -> bool
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}
Sourcepub fn is_redirection(&self) -> bool
pub fn is_redirection(&self) -> bool
Checks whether the navigation is initiated by a redirection.
Sourcepub fn is_user_initiated(&self) -> bool
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}
Sourcepub fn url(&self) -> String
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§
Auto Trait Implementations§
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