pub struct WebviewWindow(/* private fields */);
Expand description
Create new webview windows and get a handle to existing ones.
Windows are identified by a label a unique identifier that can be used to reference it later. It may only contain alphanumeric characters a-zA-Z plus the following special characters -, /, : and _.
Implementations§
source§impl WebviewWindow
impl WebviewWindow
pub fn get_by_label(label: &str) -> Option<Self>
sourcepub async fn scale_factor(&self) -> Result<f64, Error>
pub async fn scale_factor(&self) -> Result<f64, Error>
Returns the scale factor that can be used to map logical pixels to physical pixels, and vice versa.
sourcepub async fn inner_position(&self) -> Result<PhysicalPosition, Error>
pub async fn inner_position(&self) -> Result<PhysicalPosition, Error>
Returns the position of the top-left hand corner of the window’s client area relative to the top-left hand corner of the desktop.
sourcepub async fn outer_position(&self) -> Result<PhysicalPosition, Error>
pub async fn outer_position(&self) -> Result<PhysicalPosition, Error>
Returns the position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.
sourcepub async fn inner_size(&self) -> Result<PhysicalSize, Error>
pub async fn inner_size(&self) -> Result<PhysicalSize, Error>
Returns the physical size of the window’s client area.
The client area is the content of the window, excluding the title bar and borders.
sourcepub async fn outer_size(&self) -> Result<PhysicalSize, Error>
pub async fn outer_size(&self) -> Result<PhysicalSize, Error>
Returns the physical size of the entire window.
These dimensions include the title bar and borders. If you don’t want that (and you usually don’t), use inner_size instead.
sourcepub async fn is_fullscreen(&self) -> Result<bool, Error>
pub async fn is_fullscreen(&self) -> Result<bool, Error>
Gets the window’s current fullscreen state.
sourcepub async fn is_maximized(&self) -> Result<bool, Error>
pub async fn is_maximized(&self) -> Result<bool, Error>
Gets the window’s current maximized state.
sourcepub async fn is_decorated(&self) -> Result<bool, Error>
pub async fn is_decorated(&self) -> Result<bool, Error>
Gets the window’s current decoration state.
sourcepub async fn is_resizable(&self) -> Result<bool, Error>
pub async fn is_resizable(&self) -> Result<bool, Error>
Gets the window’s current resizable state.
sourcepub async fn is_visible(&self) -> Result<bool, Error>
pub async fn is_visible(&self) -> Result<bool, Error>
Gets the window’s current visibility state.
sourcepub async fn center(&self) -> Result<(), Error>
pub async fn center(&self) -> Result<(), Error>
Centers the window.
Requires allowlist > window > center
to be enabled.
sourcepub async fn request_user_attention(
&self,
request_type: UserAttentionType,
) -> Result<(), Error>
pub async fn request_user_attention( &self, request_type: UserAttentionType, ) -> Result<(), Error>
Requests user attention to the window, this has no effect if the application is already focused. How requesting for user attention manifests is platform dependent, see UserAttentionType for details.
Providing None will unset the request for user attention. Unsetting the request for user attention might not be done automatically by the WM when the window receives input.
§Platform-specific
- macOS: None has no effect.
- Linux: Urgency levels have the same effect.
Requires allowlist > window > requestUserAttention
to be enabled.
sourcepub fn print(&self) -> Result<(), Error>
pub fn print(&self) -> Result<(), Error>
Opens the dialog to prints the contents of the webview.
Currently only supported on macOS on wry. window.print() works on all platforms.
Requires allowlist > window > print
to be enabled.
sourcepub async fn set_resizable(&self, resizable: bool) -> Result<(), Error>
pub async fn set_resizable(&self, resizable: bool) -> Result<(), Error>
Determines if this window should be resizable.
Requires allowlist > window > setResizable
to be enabled.
sourcepub async fn set_title(&self, title: impl AsRef<str>) -> Result<(), Error>
pub async fn set_title(&self, title: impl AsRef<str>) -> Result<(), Error>
Set this window’s title.
Requires allowlist > window > setTitle
to be enabled.
sourcepub async fn maximize(&self) -> Result<(), Error>
pub async fn maximize(&self) -> Result<(), Error>
Maximizes this window.
Requires allowlist > window > maximize
to be enabled.
sourcepub async fn unmaximize(&self) -> Result<(), Error>
pub async fn unmaximize(&self) -> Result<(), Error>
Un-maximizes this window.
Requires allowlist > window > unmaximize
to be enabled.
pub async fn toggle_maximize(&self) -> Result<(), Error>
sourcepub async fn minimize(&self) -> Result<(), Error>
pub async fn minimize(&self) -> Result<(), Error>
Minimizes this window.
Requires allowlist > window > minimize
to be enabled.
sourcepub async fn unminimize(&self) -> Result<(), Error>
pub async fn unminimize(&self) -> Result<(), Error>
Un-minimizes this window.
Requires allowlist > window > unminimize
to be enabled.
sourcepub async fn show(&self) -> Result<(), Error>
pub async fn show(&self) -> Result<(), Error>
Show this window.
Requires allowlist > window > show
to be enabled.
sourcepub async fn hide(&self) -> Result<(), Error>
pub async fn hide(&self) -> Result<(), Error>
Hide this window.
Requires allowlist > window > hide
to be enabled.
sourcepub async fn close(&self) -> Result<(), Error>
pub async fn close(&self) -> Result<(), Error>
Closes this window.
Requires allowlist > window > close
to be enabled.
sourcepub async fn set_decorations(&self, decorations: bool) -> Result<(), Error>
pub async fn set_decorations(&self, decorations: bool) -> Result<(), Error>
Determines if this window should be decorated.
Requires allowlist > window > setDecorations
to be enabled.
sourcepub async fn set_always_on_top(&self, always_on_top: bool) -> Result<(), Error>
pub async fn set_always_on_top(&self, always_on_top: bool) -> Result<(), Error>
Determines if this window should always be on top of other windows.
Requires allowlist > window > setAlwaysOnTop
to be enabled.
sourcepub async fn set_size(&self, size: impl Into<Size>) -> Result<(), Error>
pub async fn set_size(&self, size: impl Into<Size>) -> Result<(), Error>
Resizes this window.
Requires allowlist > window > setSize
to be enabled.
sourcepub async fn set_min_size(
&self,
size: Option<impl Into<Size>>,
) -> Result<(), Error>
pub async fn set_min_size( &self, size: Option<impl Into<Size>>, ) -> Result<(), Error>
Sets this window’s minimum size.
Requires allowlist > window > setMinSize
to be enabled.
sourcepub async fn set_max_size(
&self,
size: Option<impl Into<Size>>,
) -> Result<(), Error>
pub async fn set_max_size( &self, size: Option<impl Into<Size>>, ) -> Result<(), Error>
Sets this window’s maximum size.
Requires allowlist > window > setMaxSize
to be enabled.
sourcepub async fn set_position(
&self,
position: impl Into<Position>,
) -> Result<(), Error>
pub async fn set_position( &self, position: impl Into<Position>, ) -> Result<(), Error>
Sets this window’s position.
Requires allowlist > window > setPosition
to be enabled.
sourcepub async fn set_fullscreen(&self, fullscreen: bool) -> Result<(), Error>
pub async fn set_fullscreen(&self, fullscreen: bool) -> Result<(), Error>
Determines if this window should be fullscreen.
Requires allowlist > window > setFullscreen
to be enabled.
sourcepub async fn set_focus(&self) -> Result<(), Error>
pub async fn set_focus(&self) -> Result<(), Error>
Bring the window to front and focus.
Requires allowlist > window > setFocus
to be enabled.
sourcepub async fn set_icon(&self, icon: &[u8]) -> Result<(), Error>
pub async fn set_icon(&self, icon: &[u8]) -> Result<(), Error>
Sets this window’ icon.
Requires allowlist > window > setIcon
to be enabled.
sourcepub async fn set_skip_taskbar(&self, skip: bool) -> Result<(), Error>
pub async fn set_skip_taskbar(&self, skip: bool) -> Result<(), Error>
Whether to show the window icon in the task bar or not.
Requires allowlist > window > setSkipTaskbar
to be enabled.
sourcepub async fn set_cursor_grab(&self, grab: bool) -> Result<(), Error>
pub async fn set_cursor_grab(&self, grab: bool) -> Result<(), Error>
Grabs the cursor, preventing it from leaving the window.
There’s no guarantee that the cursor will be hidden. You should hide it by yourself if you want so.
§Platform-specific
- Linux: Unsupported.
- macOS: This locks the cursor in a fixed location, which looks visually awkward.
Requires allowlist > window > setCursorGrab
to be enabled.
sourcepub async fn set_cursor_visible(&self, visible: bool) -> Result<(), Error>
pub async fn set_cursor_visible(&self, visible: bool) -> Result<(), Error>
Modifies the cursor’s visibility.
If false, this will hide the cursor. If true, this will show the cursor.
§Platform-specific
- Windows: The cursor is only hidden within the confines of the window.
- macOS: The cursor is hidden as long as the window has input focus, even if the cursor is outside of the window.
Requires allowlist > window > setCursorVisible
to be enabled.
sourcepub async fn set_cursor_icon(&self, icon: CursorIcon) -> Result<(), Error>
pub async fn set_cursor_icon(&self, icon: CursorIcon) -> Result<(), Error>
Modifies the cursor icon of the window.
Requires allowlist > window > setCursorIcon
to be enabled.
sourcepub async fn set_cursor_position(&self, position: Position) -> Result<(), Error>
pub async fn set_cursor_position(&self, position: Position) -> Result<(), Error>
Changes the position of the cursor in window coordinates.
Requires allowlist > window > setCursorPosition
to be enabled.
sourcepub async fn set_ignore_cursor_events(&self, ignore: bool) -> Result<(), Error>
pub async fn set_ignore_cursor_events(&self, ignore: bool) -> Result<(), Error>
Ignores the window cursor events.
Requires allowlist > window > setIgnoreCursorEvents
to be enabled.
sourcepub async fn start_dragging(&self) -> Result<(), Error>
pub async fn start_dragging(&self) -> Result<(), Error>
Starts dragging the window.
Requires allowlist > window > startDragging
to be enabled.
sourcepub async fn emit<T: Serialize>(
&self,
event: &str,
payload: &T,
) -> Result<(), Error>
pub async fn emit<T: Serialize>( &self, event: &str, payload: &T, ) -> Result<(), Error>
Emits an event to the backend, tied to the webview window.
sourcepub async fn listen<T>(
&self,
event: &str,
) -> Result<impl Stream<Item = Event<T>>, Error>where
T: DeserializeOwned + 'static,
pub async fn listen<T>(
&self,
event: &str,
) -> Result<impl Stream<Item = Event<T>>, Error>where
T: DeserializeOwned + 'static,
Listen to an event emitted by the backend that is tied to the webview window.
The returned Future will automatically clean up it’s underlying event listener when dropped, so no manual unlisten function needs to be called. See Differences to the JavaScript API for details.
sourcepub async fn once<T>(&self, event: &str) -> Result<Event<T>, Error>where
T: DeserializeOwned + 'static,
pub async fn once<T>(&self, event: &str) -> Result<Event<T>, Error>where
T: DeserializeOwned + 'static,
Listen to an one-off event emitted by the backend that is tied to the webview window.
The returned Future will automatically clean up it’s underlying event listener when dropped, so no manual unlisten function needs to be called. See Differences to the JavaScript API for details.
Trait Implementations§
source§impl Clone for WebviewWindow
impl Clone for WebviewWindow
source§fn clone(&self) -> WebviewWindow
fn clone(&self) -> WebviewWindow
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for WebviewWindow
impl Debug for WebviewWindow
source§impl PartialEq for WebviewWindow
impl PartialEq for WebviewWindow
impl StructuralPartialEq for WebviewWindow
Auto Trait Implementations§
impl Freeze for WebviewWindow
impl RefUnwindSafe for WebviewWindow
impl !Send for WebviewWindow
impl !Sync for WebviewWindow
impl Unpin for WebviewWindow
impl UnwindSafe for WebviewWindow
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
)