Struct tauri_sys::window::WebviewWindow

source ·
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

source

pub fn get_by_label(label: &str) -> Option<Self>

source

pub fn label(&self) -> String

The label of this window.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub async fn is_fullscreen(&self) -> Result<bool, Error>

Gets the window’s current fullscreen state.

source

pub async fn is_maximized(&self) -> Result<bool, Error>

Gets the window’s current maximized state.

source

pub async fn is_decorated(&self) -> Result<bool, Error>

Gets the window’s current decoration state.

source

pub async fn is_resizable(&self) -> Result<bool, Error>

Gets the window’s current resizable state.

source

pub async fn is_visible(&self) -> Result<bool, Error>

Gets the window’s current visibility state.

source

pub async fn theme(&self) -> Result<Theme, Error>

Returns the current window theme.

§Platform-specific
  • macOS: Only supported on macOS 10.14+.
source

pub async fn center(&self) -> Result<(), Error>

Centers the window.

Requires allowlist > window > center to be enabled.

source

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.

source

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.

source

pub async fn set_resizable(&self, resizable: bool) -> Result<(), Error>

Determines if this window should be resizable.

Requires allowlist > window > setResizable to be enabled.

source

pub async fn set_title(&self, title: impl AsRef<str>) -> Result<(), Error>

Set this window’s title.

Requires allowlist > window > setTitle to be enabled.

source

pub async fn maximize(&self) -> Result<(), Error>

Maximizes this window.

Requires allowlist > window > maximize to be enabled.

source

pub async fn unmaximize(&self) -> Result<(), Error>

Un-maximizes this window.

Requires allowlist > window > unmaximize to be enabled.

source

pub async fn toggle_maximize(&self) -> Result<(), Error>

source

pub async fn minimize(&self) -> Result<(), Error>

Minimizes this window.

Requires allowlist > window > minimize to be enabled.

source

pub async fn unminimize(&self) -> Result<(), Error>

Un-minimizes this window.

Requires allowlist > window > unminimize to be enabled.

source

pub async fn show(&self) -> Result<(), Error>

Show this window.

Requires allowlist > window > show to be enabled.

source

pub async fn hide(&self) -> Result<(), Error>

Hide this window.

Requires allowlist > window > hide to be enabled.

source

pub async fn close(&self) -> Result<(), Error>

Closes this window.

Requires allowlist > window > close to be enabled.

source

pub async fn set_decorations(&self, decorations: bool) -> Result<(), Error>

Determines if this window should be decorated.

Requires allowlist > window > setDecorations to be enabled.

source

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.

source

pub async fn set_size(&self, size: impl Into<Size>) -> Result<(), Error>

Resizes this window.

Requires allowlist > window > setSize to be enabled.

source

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.

source

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.

source

pub async fn set_position( &self, position: impl Into<Position>, ) -> Result<(), Error>

Sets this window’s position.

Requires allowlist > window > setPosition to be enabled.

source

pub async fn set_fullscreen(&self, fullscreen: bool) -> Result<(), Error>

Determines if this window should be fullscreen.

Requires allowlist > window > setFullscreen to be enabled.

source

pub async fn set_focus(&self) -> Result<(), Error>

Bring the window to front and focus.

Requires allowlist > window > setFocus to be enabled.

source

pub async fn set_icon(&self, icon: &[u8]) -> Result<(), Error>

Sets this window’ icon.

Requires allowlist > window > setIcon to be enabled.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub async fn set_ignore_cursor_events(&self, ignore: bool) -> Result<(), Error>

Ignores the window cursor events.

Requires allowlist > window > setIgnoreCursorEvents to be enabled.

source

pub async fn start_dragging(&self) -> Result<(), Error>

Starts dragging the window.

Requires allowlist > window > startDragging to be enabled.

source

pub async fn emit<T: Serialize>( &self, event: &str, payload: &T, ) -> Result<(), Error>

Emits an event to the backend, tied to the webview window.

source

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.

source

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

source§

fn clone(&self) -> WebviewWindow

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for WebviewWindow

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for WebviewWindow

source§

fn eq(&self, other: &WebviewWindow) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for WebviewWindow

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.