pub struct WebView { /* private fields */ }
Expand description
The fundamental type to present a WebView
.
WebViewBuilder
/ WebView
are the basic building blocks to construct WebView contents and
scripts for those who prefer to control fine grained window creation and event handling.
WebView
presents the actual WebView window and let you still able to perform actions
during event handling to it. WebView
also contains the associate Window
with it.
Implementations§
source§impl 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 open_devtools(&self)
pub fn open_devtools(&self)
Open the web inspector which is usually called dev tool.
Platform-specific
- Android / iOS: Not supported.
sourcepub fn close_devtools(&self)
pub fn close_devtools(&self)
Close the web inspector which is usually called dev tool.
Platform-specific
- Windows / Android / iOS: Not supported.
sourcepub fn is_devtools_open(&self) -> bool
pub fn is_devtools_open(&self) -> bool
Gets the devtool window’s current visibility state.
Platform-specific
- Windows / Android / iOS: Not supported.
pub fn inner_size(&self) -> PhysicalSize<u32>
sourcepub fn zoom(&self, scale_factor: f64)
pub fn zoom(&self, scale_factor: f64)
Set the webview zoom level
Platform-specific:
- Android: Not supported.
- macOS: available on macOS 11+ only.
- iOS: available on iOS 14+ only.
sourcepub fn set_background_color(&self, background_color: RGBA) -> Result<()>
pub fn set_background_color(&self, background_color: RGBA) -> Result<()>
Specify the webview background color.
The color uses the RGBA format.
Platfrom-specific:
- macOS / iOS: 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 by255