pub struct WebView { /* private fields */ }
Expand description
WebView is a Window running as program including a web view
WebView has to be built with the help of the WebView::builder
function
Implementations§
source§impl WebView
impl WebView
sourcepub fn builder(app: &Application) -> WebViewBuilder<'_>
pub fn builder(app: &Application) -> WebViewBuilder<'_>
Creates a WebViewBuilder
to construct a WebView.
Call several WebViewBuilder functions and create the WebView with build()
§Example
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
Allows console to show up in debug build but not release build.
use webview_app::webview::WebView;
fn on_activate(app: &Application)->WebView {
let webview =
WebView::builder()
.appid("de.uriegel.hello")
.title("Rust Web View 🦞")
.url("https://crates.io/crates/webview_app")
.build();
webview
}
sourcepub fn can_close(&self, val: impl Fn() -> bool + 'static)
pub fn can_close(&self, val: impl Fn() -> bool + 'static)
Sets a callback which is invoked on closing the app
You can prevent closing the app when returning false
§Example
let can_close = true;
...
webview.can_close(move ||can_close);
sourcepub fn connect_request<F: Fn(&Request, String, String, String) -> bool + 'static>(
&self,
on_request: F,
)
pub fn connect_request<F: Fn(&Request, String, String, String) -> bool + 'static>( &self, on_request: F, )
When the webview is created, this callback is being called. You can then install WebView requests.
The Callback function has the following parameters: a request object, the request id, the command id (the Webview method) and the JSON payload.
A true return value signals that the request is being processed by this callback.
sourcepub fn get_handle(&self) -> WebViewHandle
pub fn get_handle(&self) -> WebViewHandle
Retrieving a WebViewHandle to evaluate script in the WebView
sourcepub fn eval(handle: WebViewHandle, script: &str)
pub fn eval(handle: WebViewHandle, script: &str)
Evaluates script in the WebView
You need a WebViewHandle which you can retrieve via WebView::get_handle
You do not need a reference to the WebView handle!
Trait Implementations§
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> 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)