Skip to main content

Struct tauri::window::Window

pub struct Window<R: Runtime = Wry> { /* fields omitted */ }

Expand description

A webview window managed by Tauri.

This type also implements Manager which allows you to manage other windows attached to the same application.

Implementations#

impl<R: Runtime> Window<R>[src]#

pub fn create_window<F>( &mut self, label: String, url: WindowUrl, setup: F ) -> Result<Window<R>> where F: FnOnce(<R::Dispatcher as Dispatch>::WindowBuilder, WebviewAttributes) -> (<R::Dispatcher as Dispatch>::WindowBuilder, WebviewAttributes),[src]#

Creates a new webview window.

pub fn label(&self) -> &str[src]#

The label of this window.

pub fn emit<S: Serialize>(&self, event: &str, payload: S) -> Result<()>[src]#

Emits an event to the current window.

pub fn emit_others<S: Serialize + Clone>( &self, event: &str, payload: S ) -> Result<()>[src]#

Emits an event on all windows except this one.

pub fn listen<F>(&self, event: impl Into<String>, handler: F) -> EventHandler where F: Fn(Event) + Send + 'static,[src]#

Listen to an event on this window.

pub fn once<F>(&self, event: impl Into<String>, handler: F) -> EventHandler where F: Fn(Event) + Send + 'static,[src]#

Listen to a an event on this window a single time.

pub fn trigger(&self, event: &str, data: Option<String>)[src]#

Triggers an event on this window.

pub fn eval(&self, js: &str) -> Result<()>[src]#

Evaluates JavaScript on this window.

pub fn on_window_event<F: Fn(&WindowEvent) + Send + 'static>(&self, f: F)[src]#

Registers a window event listener.

pub fn on_menu_event<F: Fn(MenuEvent) + Send + 'static>(&self, f: F) -> Uuid[src]#

Registers a menu event listener.

pub fn menu_handle(&self) -> MenuHandle<R>[src]#

Gets a handle to the window menu.

pub fn scale_factor(&self) -> Result<f64>[src]#

Returns the scale factor that can be used to map logical pixels to physical pixels, and vice versa.

Panics#

  • Panics if the event loop is not running yet, usually when called on the setup closure.
  • Panics when called on the main thread, usually on the run closure.

You can spawn a task to use the API using crate::async_runtime::spawn or std::thread::spawn to prevent the panic.

pub fn inner_position(&self) -> Result<PhysicalPosition<i32>>[src]#

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.

Panics#

  • Panics if the event loop is not running yet, usually when called on the setup closure.
  • Panics when called on the main thread, usually on the run closure.

You can spawn a task to use the API using crate::async_runtime::spawn or std::thread::spawn to prevent the panic.

pub fn outer_position(&self) -> Result<PhysicalPosition<i32>>[src]#

Returns the position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.

Panics#

  • Panics if the event loop is not running yet, usually when called on the setup closure.
  • Panics when called on the main thread, usually on the run closure.

You can spawn a task to use the API using crate::async_runtime::spawn or std::thread::spawn to prevent the panic.

pub fn inner_size(&self) -> Result<PhysicalSize<u32>>[src]#

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.

Panics#

  • Panics if the event loop is not running yet, usually when called on the setup closure.
  • Panics when called on the main thread, usually on the run closure.

You can spawn a task to use the API using crate::async_runtime::spawn or std::thread::spawn to prevent the panic.

pub fn outer_size(&self) -> Result<PhysicalSize<u32>>[src]#

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.

Panics#

  • Panics if the event loop is not running yet, usually when called on the setup closure.
  • Panics when called on the main thread, usually on the run closure.

You can spawn a task to use the API using crate::async_runtime::spawn or std::thread::spawn to prevent the panic.

pub fn is_fullscreen(&self) -> Result<bool>[src]#

Gets the window’s current fullscreen state.

Panics#

  • Panics if the event loop is not running yet, usually when called on the setup closure.
  • Panics when called on the main thread, usually on the run closure.

You can spawn a task to use the API using crate::async_runtime::spawn or std::thread::spawn to prevent the panic.

pub fn is_maximized(&self) -> Result<bool>[src]#

Gets the window’s current maximized state.

Panics#

  • Panics if the event loop is not running yet, usually when called on the setup closure.
  • Panics when called on the main thread, usually on the run closure.

You can spawn a task to use the API using crate::async_runtime::spawn or std::thread::spawn to prevent the panic.

pub fn is_decorated(&self) -> Result<bool>[src]#

Gets the window’s current decoration state.

Panics#

  • Panics if the event loop is not running yet, usually when called on the setup closure.
  • Panics when called on the main thread, usually on the run closure.

You can spawn a task to use the API using crate::async_runtime::spawn or std::thread::spawn to prevent the panic.

pub fn is_resizable(&self) -> Result<bool>[src]#

Gets the window’s current resizable state.

Panics#

  • Panics if the event loop is not running yet, usually when called on the setup closure.
  • Panics when called on the main thread, usually on the run closure.

You can spawn a task to use the API using crate::async_runtime::spawn or std::thread::spawn to prevent the panic.

pub fn is_visible(&self) -> Result<bool>[src]#

Gets the window’s current vibility state.

Panics#

  • Panics if the event loop is not running yet, usually when called on the setup closure.
  • Panics when called on the main thread, usually on the run closure.

You can spawn a task to use the API using crate::async_runtime::spawn or std::thread::spawn to prevent the panic.

pub fn current_monitor(&self) -> Result<Option<Monitor>>[src]#

Returns the monitor on which the window currently resides.

Returns None if current monitor can’t be detected.

Platform-specific#

  • Linux: Unsupported

Panics#

  • Panics if the event loop is not running yet, usually when called on the setup closure.
  • Panics when called on the main thread, usually on the run closure.

You can spawn a task to use the API using crate::async_runtime::spawn or std::thread::spawn to prevent the panic.

pub fn primary_monitor(&self) -> Result<Option<Monitor>>[src]#

Returns the primary monitor of the system.

Returns None if it can’t identify any monitor as a primary one.

Platform-specific#

  • Linux: Unsupported

Panics#

  • Panics if the event loop is not running yet, usually when called on the setup closure.
  • Panics when called on the main thread, usually on the run closure.

You can spawn a task to use the API using crate::async_runtime::spawn or std::thread::spawn to prevent the panic.

pub fn available_monitors(&self) -> Result<Vec<Monitor>>[src]#

Returns the list of all the monitors available on the system.

Platform-specific#

  • Linux: Unsupported

Panics#

  • Panics if the event loop is not running yet, usually when called on the setup closure.
  • Panics when called on the main thread, usually on the run closure.

You can spawn a task to use the API using crate::async_runtime::spawn or std::thread::spawn to prevent the panic.

pub fn gtk_window(&self) -> Result<ApplicationWindow>[src]#

Returns the ApplicatonWindow from gtk crate that is used by this window.

Note that this can only be used on the main thread.

pub fn center(&self) -> Result<()>[src]#

Centers the window.

pub fn request_user_attention( &self, request_type: Option<UserAttentionType> ) -> Result<()>[src]#

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.

pub fn print(&self) -> Result<()>[src]#

Opens the dialog to prints the contents of the webview. Currently only supported on macOS on wry. window.print() works on all platforms.

pub fn set_resizable(&self, resizable: bool) -> Result<()>[src]#

Determines if this window should be resizable.

pub fn set_title(&self, title: &str) -> Result<()>[src]#

Set this window’s title.

pub fn maximize(&self) -> Result<()>[src]#

Maximizes this window.

pub fn unmaximize(&self) -> Result<()>[src]#

Un-maximizes this window.

pub fn minimize(&self) -> Result<()>[src]#

Minimizes this window.

pub fn unminimize(&self) -> Result<()>[src]#

Un-minimizes this window.

pub fn show(&self) -> Result<()>[src]#

Show this window.

pub fn hide(&self) -> Result<()>[src]#

Hide this window.

pub fn close(&self) -> Result<()>[src]#

Closes this window.

pub fn set_decorations(&self, decorations: bool) -> Result<()>[src]#

Determines if this window should be decorated.

pub fn set_always_on_top(&self, always_on_top: bool) -> Result<()>[src]#

Determines if this window should always be on top of other windows.

pub fn set_size<S: Into<Size>>(&self, size: S) -> Result<()>[src]#

Resizes this window.

pub fn set_min_size<S: Into<Size>>(&self, size: Option<S>) -> Result<()>[src]#

Sets this window’s minimum size.

pub fn set_max_size<S: Into<Size>>(&self, size: Option<S>) -> Result<()>[src]#

Sets this window’s maximum size.

pub fn set_position<Pos: Into<Position>>(&self, position: Pos) -> Result<()>[src]#

Sets this window’s position.

pub fn set_fullscreen(&self, fullscreen: bool) -> Result<()>[src]#

Determines if this window should be fullscreen.

pub fn set_focus(&self) -> Result<()>[src]#

Bring the window to front and focus.

pub fn set_icon(&self, icon: Icon) -> Result<()>[src]#

Sets this window’ icon.

pub fn set_skip_taskbar(&self, skip: bool) -> Result<()>[src]#

Whether to show the window icon in the task bar or not.

pub fn start_dragging(&self) -> Result<()>[src]#

Starts dragging the window.

Trait Implementations#

impl<R: Runtime> Clone for Window<R>[src]#

fn clone(&self) -> Self[src]#

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]#

Performs copy-assignment from source. Read more

impl<'de, R: Runtime> CommandArg<'de, R> for Window<R>[src]#

fn from_command(command: CommandItem<'de, R>) -> Result<Self, InvokeError>[src]#

Grabs the Window from the CommandItem. This will never fail.

impl<R: Debug + Runtime> Debug for Window<R>[src]#

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

Formats the value using the given formatter. Read more

impl<R: Runtime> Hash for Window<R>[src]#

fn hash<H: Hasher>(&self, state: &mutH)[src]#

Only use the Window’s label to represent its hash.

fn hash_slice<H>(data: &[Self], state: &mutH) where H: Hasher,1.3.0[src]#

Feeds a slice of this type into the given Hasher. Read more

impl<R: Runtime> Manager<R> for Window<R>[src]#

fn config(&self) -> Arc<Config>[src]#

The Config the manager was created with.

fn emit_all<S: Serialize + Clone>(&self, event: &str, payload: S) -> Result<()>[src]#

Emits a event to all windows.

fn emit_to<S: Serialize + Clone>( &self, label: &str, event: &str, payload: S ) -> Result<()>[src]#

Emits an event to a window with the specified label.

fn listen_global<F>(&self, event: impl Into<String>, handler: F) -> EventHandler where F: Fn(EmittedEvent) + Send + 'static,[src]#

Listen to a global event.

fn once_global<F>(&self, event: impl Into<String>, handler: F) -> EventHandler where F: Fn(EmittedEvent) + Send + 'static,[src]#

Listen to a global event only once.

fn trigger_global(&self, event: &str, data: Option<String>)[src]#

Trigger a global event.

fn unlisten(&self, handler_id: EventHandler)[src]#

Remove an event listener.

fn get_window(&self, label: &str) -> Option<Window<R>>[src]#

Fetch a single window from the manager.

fn windows(&self) -> HashMap<String, Window<R>>[src]#

Fetch all managed windows.

fn manage<T>(&self, state: T) where T: Send + Sync + 'static,[src]#

Add state to the state managed by the application. See crate::Builder for instructions. Read more

fn state<T>(&self) -> State<'_, T> where T: Send + Sync + 'static,[src]#

Gets the managed state for the type T. Panics if the type is not managed.

fn try_state<T>(&self) -> Option<State<'_, T>> where T: Send + Sync + 'static,[src]#

Tries to get the managed state for the type T. Returns None if the type is not managed.

impl<R: Runtime> PartialEq<Window<R>> for Window<R>[src]#

fn eq(&self, other: &Self) -> bool[src]#

Only use the Window’s label to compare equality.

#[must_use]fn ne(&self, other: &Rhs) -> bool1.0.0[src]#

This method tests for !=.

impl<R: Runtime> Eq for Window<R>#

[src]

Auto Trait Implementations#

impl<R = Wry> \!RefUnwindSafe for Window<R>#

impl<R> Send for Window<R>#

impl<R> Sync for Window<R> where <R as Runtime>::ClipboardManager: Sync, <R as Runtime>::Dispatcher: Sync, <R as Runtime>::GlobalShortcutManager: Sync, <R as Runtime>::Handle: Sync,#

impl<R> Unpin for Window<R> where <R as Runtime>::ClipboardManager: Unpin, <R as Runtime>::Dispatcher: Unpin, <R as Runtime>::GlobalShortcutManager: Unpin, <R as Runtime>::Handle: Unpin,#

impl<R = Wry> \!UnwindSafe for Window<R>#

Blanket Implementations#

impl<T> Any for T where T: 'static + ?Sized,[src]#

pub fn type_id(&self) -> TypeId[src]#

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where T: ?Sized,[src]#

pub fn borrow(&self) -> &T[src]#

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where T: ?Sized,[src]#

pub fn borrow_mut(&mut self) -> &mutT[src]#

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]#

pub fn from(t: T) -> T[src]#

Performs the conversion.

impl<T, U> Into<U> for T where U: From<T>,[src]#

pub fn into(self) -> U[src]#

Performs the conversion.

impl<T> ToOwned for T where T: Clone,[src]#

type Owned = T#

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]#

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

pub fn clone_into(&self, target: &mutT)[src]#

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where U: Into<T>,[src]#

type Error = Infallible#

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]#

Performs the conversion.

impl<T, U> TryInto<U> for T where U: TryFrom<T>,[src]#

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

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]#

Performs the conversion.

impl<V, T> VZip<V> for T where V: MultiLane<T>,#

pub fn vzip(self) -> V#