pub struct WebView { /* private fields */ }
Expand description
The fundamental type to present a WebView
.
WebViewBuilder
/ WebView
are the basic building blocks to constrcut WebView contents and
scripts for those who prefer to control fine grained window creation and event handling.
WebView
presents the actuall WebView window and let you still able to perform actions
during event handling to it. WebView
also contains the associate Window
with it.
Implementations
sourceimpl WebView
impl WebView
sourcepub fn new(window: Window) -> Result<Self>
pub fn new(window: Window) -> Result<Self>
Create a WebView
from provided Window
. Note that calling this directly loses
abilities to initialize scripts, add ipc handler, and many more before starting WebView. To
benefit from above features, create a WebViewBuilder
instead.
Platform-specific behavior:
- Unix: This method must be called in a gtk thread. Usually this means it should be
called in the same thread with the
EventLoop
you create.
sourcepub fn evaluate_script(&self, js: &str) -> Result<()>
pub fn evaluate_script(&self, js: &str) -> Result<()>
Evaluate and run javascript code. Must be called on the same thread who created the
WebView
. Use EventLoopProxy
and a custom event to send scripts from other threads.
sourcepub fn resize(&self) -> Result<()>
pub fn resize(&self) -> Result<()>
Resize the WebView manually. This is only required on Windows because its WebView API doesn’t provide a way to resize automatically.
sourcepub fn focus(&self)
pub fn focus(&self)
Moves Focus to the Webview control.
It’s usually safe to call focus
method on Window
which would also focus to WebView
except Windows.
Focussing to Window
doesn’t mean focussing to WebView
on Windows. For example, if you have
an input field on webview and lost focus, you will have to explicitly click the field even you
re-focus the window. And if you focus to WebView
, it will lost focus to the Window
.
pub fn inner_size(&self) -> PhysicalSize<u32>
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for WebView
impl !Send for WebView
impl !Sync for WebView
impl Unpin for WebView
impl !UnwindSafe for WebView
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more