Trait tauri_runtime::Dispatch

source ·
pub trait Dispatch<T: UserEvent>:
    Debug
    + Clone
    + Send
    + Sync
    + Sized
    + 'static {
    type Runtime: Runtime<T>;
    type WindowBuilder: WindowBuilder;

Show 67 methods // Required methods fn run_on_main_thread<F: FnOnce() + Send + 'static>( &self, f: F, ) -> Result<()>; fn on_window_event<F: Fn(&WindowEvent) + Send + 'static>( &self, f: F, ) -> Uuid; fn on_menu_event<F: Fn(&MenuEvent) + Send + 'static>(&self, f: F) -> Uuid; fn open_devtools(&self); fn close_devtools(&self); fn is_devtools_open(&self) -> Result<bool>; fn url(&self) -> Result<Url>; fn scale_factor(&self) -> Result<f64>; fn inner_position(&self) -> Result<PhysicalPosition<i32>>; fn outer_position(&self) -> Result<PhysicalPosition<i32>>; fn inner_size(&self) -> Result<PhysicalSize<u32>>; fn outer_size(&self) -> Result<PhysicalSize<u32>>; fn is_fullscreen(&self) -> Result<bool>; fn is_minimized(&self) -> Result<bool>; fn is_maximized(&self) -> Result<bool>; fn is_focused(&self) -> Result<bool>; fn is_decorated(&self) -> Result<bool>; fn is_resizable(&self) -> Result<bool>; fn is_maximizable(&self) -> Result<bool>; fn is_minimizable(&self) -> Result<bool>; fn is_closable(&self) -> Result<bool>; fn is_visible(&self) -> Result<bool>; fn title(&self) -> Result<String>; fn is_menu_visible(&self) -> Result<bool>; fn current_monitor(&self) -> Result<Option<Monitor>>; fn primary_monitor(&self) -> Result<Option<Monitor>>; fn available_monitors(&self) -> Result<Vec<Monitor>>; fn gtk_window(&self) -> Result<ApplicationWindow>; fn raw_window_handle(&self) -> Result<RawWindowHandle>; fn theme(&self) -> Result<Theme>; fn center(&self) -> Result<()>; fn print(&self) -> Result<()>; fn request_user_attention( &self, request_type: Option<UserAttentionType>, ) -> Result<()>; fn create_window( &mut self, pending: PendingWindow<T, Self::Runtime>, ) -> Result<DetachedWindow<T, Self::Runtime>>; fn set_resizable(&self, resizable: bool) -> Result<()>; fn set_maximizable(&self, maximizable: bool) -> Result<()>; fn set_minimizable(&self, minimizable: bool) -> Result<()>; fn set_closable(&self, closable: bool) -> Result<()>; fn set_title<S: Into<String>>(&self, title: S) -> Result<()>; fn maximize(&self) -> Result<()>; fn unmaximize(&self) -> Result<()>; fn minimize(&self) -> Result<()>; fn unminimize(&self) -> Result<()>; fn show_menu(&self) -> Result<()>; fn hide_menu(&self) -> Result<()>; fn show(&self) -> Result<()>; fn hide(&self) -> Result<()>; fn close(&self) -> Result<()>; fn set_decorations(&self, decorations: bool) -> Result<()>; fn set_always_on_top(&self, always_on_top: bool) -> Result<()>; fn set_content_protected(&self, protected: bool) -> Result<()>; fn set_size(&self, size: Size) -> Result<()>; fn set_min_size(&self, size: Option<Size>) -> Result<()>; fn set_max_size(&self, size: Option<Size>) -> Result<()>; fn set_position(&self, position: Position) -> Result<()>; fn set_fullscreen(&self, fullscreen: bool) -> Result<()>; fn set_focus(&self) -> Result<()>; fn set_icon(&self, icon: Icon) -> Result<()>; fn set_skip_taskbar(&self, skip: bool) -> Result<()>; fn set_cursor_grab(&self, grab: bool) -> Result<()>; fn set_cursor_visible(&self, visible: bool) -> Result<()>; fn set_cursor_icon(&self, icon: CursorIcon) -> Result<()>; fn set_cursor_position<Pos: Into<Position>>( &self, position: Pos, ) -> Result<()>; fn set_ignore_cursor_events(&self, ignore: bool) -> Result<()>; fn start_dragging(&self) -> Result<()>; fn eval_script<S: Into<String>>(&self, script: S) -> Result<()>; fn update_menu_item(&self, id: u16, update: MenuUpdate) -> Result<()>;
}
Expand description

Webview dispatcher. A thread-safe handle to the webview API.

Required Associated Types§

source

type Runtime: Runtime<T>

The runtime this Dispatch runs under.

source

type WindowBuilder: WindowBuilder

The window builder type.

Required Methods§

source

fn run_on_main_thread<F: FnOnce() + Send + 'static>(&self, f: F) -> Result<()>

Run a task on the main thread.

source

fn on_window_event<F: Fn(&WindowEvent) + Send + 'static>(&self, f: F) -> Uuid

Registers a window event handler.

source

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

Registers a window event handler.

source

fn open_devtools(&self)

Open the web inspector which is usually called devtools.

source

fn close_devtools(&self)

Close the web inspector which is usually called devtools.

source

fn is_devtools_open(&self) -> Result<bool>

Gets the devtools window’s current open state.

source

fn url(&self) -> Result<Url>

Returns the webview’s current URL.

source

fn scale_factor(&self) -> Result<f64>

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

source

fn inner_position(&self) -> Result<PhysicalPosition<i32>>

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

fn outer_position(&self) -> Result<PhysicalPosition<i32>>

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

source

fn inner_size(&self) -> Result<PhysicalSize<u32>>

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

fn outer_size(&self) -> Result<PhysicalSize<u32>>

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

fn is_fullscreen(&self) -> Result<bool>

Gets the window’s current fullscreen state.

source

fn is_minimized(&self) -> Result<bool>

Gets the window’s current minimized state.

source

fn is_maximized(&self) -> Result<bool>

Gets the window’s current maximized state.

source

fn is_focused(&self) -> Result<bool>

Gets the window’s current focus state.

source

fn is_decorated(&self) -> Result<bool>

Gets the window’s current decoration state.

source

fn is_resizable(&self) -> Result<bool>

Gets the window’s current resizable state.

source

fn is_maximizable(&self) -> Result<bool>

Gets the window’s native maximize button state.

§Platform-specific
  • Linux / iOS / Android: Unsupported.
source

fn is_minimizable(&self) -> Result<bool>

Gets the window’s native minize button state.

§Platform-specific
  • Linux / iOS / Android: Unsupported.
source

fn is_closable(&self) -> Result<bool>

Gets the window’s native close button state.

§Platform-specific
  • iOS / Android: Unsupported.
source

fn is_visible(&self) -> Result<bool>

Gets the window’s current visibility state.

source

fn title(&self) -> Result<String>

Gets the window’s current title.

source

fn is_menu_visible(&self) -> Result<bool>

Gets the window menu current visibility state.

source

fn current_monitor(&self) -> Result<Option<Monitor>>

Returns the monitor on which the window currently resides.

Returns None if current monitor can’t be detected.

source

fn primary_monitor(&self) -> Result<Option<Monitor>>

Returns the primary monitor of the system.

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

source

fn available_monitors(&self) -> Result<Vec<Monitor>>

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

source

fn gtk_window(&self) -> Result<ApplicationWindow>

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

source

fn raw_window_handle(&self) -> Result<RawWindowHandle>

source

fn theme(&self) -> Result<Theme>

Returns the current window theme.

source

fn center(&self) -> Result<()>

Centers the window.

source

fn print(&self) -> Result<()>

Opens the dialog to prints the contents of the webview.

source

fn request_user_attention( &self, request_type: Option<UserAttentionType>, ) -> Result<()>

Requests user attention to the window.

Providing None will unset the request for user attention.

source

fn create_window( &mut self, pending: PendingWindow<T, Self::Runtime>, ) -> Result<DetachedWindow<T, Self::Runtime>>

Create a new webview window.

source

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

Updates the window resizable flag.

source

fn set_maximizable(&self, maximizable: bool) -> Result<()>

Updates the window’s native maximize button state.

§Platform-specific
  • macOS: Disables the “zoom” button in the window titlebar, which is also used to enter fullscreen mode.
  • Linux / iOS / Android: Unsupported.
source

fn set_minimizable(&self, minimizable: bool) -> Result<()>

Updates the window’s native minimize button state.

§Platform-specific
  • Linux / iOS / Android: Unsupported.
source

fn set_closable(&self, closable: bool) -> Result<()>

Updates the window’s native close button state.

§Platform-specific
  • Linux: “GTK+ will do its best to convince the window manager not to show a close button. Depending on the system, this function may not have any effect when called on a window that is already visible”
  • iOS / Android: Unsupported.
source

fn set_title<S: Into<String>>(&self, title: S) -> Result<()>

Updates the window title.

source

fn maximize(&self) -> Result<()>

Maximizes the window.

source

fn unmaximize(&self) -> Result<()>

Unmaximizes the window.

source

fn minimize(&self) -> Result<()>

Minimizes the window.

source

fn unminimize(&self) -> Result<()>

Unminimizes the window.

source

fn show_menu(&self) -> Result<()>

Shows the window menu.

source

fn hide_menu(&self) -> Result<()>

Hides the window menu.

source

fn show(&self) -> Result<()>

Shows the window.

source

fn hide(&self) -> Result<()>

Hides the window.

source

fn close(&self) -> Result<()>

Closes the window.

source

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

Updates the hasDecorations flag.

source

fn set_always_on_top(&self, always_on_top: bool) -> Result<()>

Updates the window alwaysOnTop flag.

source

fn set_content_protected(&self, protected: bool) -> Result<()>

Prevents the window contents from being captured by other apps.

source

fn set_size(&self, size: Size) -> Result<()>

Resizes the window.

source

fn set_min_size(&self, size: Option<Size>) -> Result<()>

Updates the window min size.

source

fn set_max_size(&self, size: Option<Size>) -> Result<()>

Updates the window max size.

source

fn set_position(&self, position: Position) -> Result<()>

Updates the window position.

source

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

Updates the window fullscreen state.

source

fn set_focus(&self) -> Result<()>

Bring the window to front and focus.

source

fn set_icon(&self, icon: Icon) -> Result<()>

Updates the window icon.

source

fn set_skip_taskbar(&self, skip: bool) -> Result<()>

Whether to hide the window icon from the taskbar or not.

source

fn set_cursor_grab(&self, grab: bool) -> Result<()>

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.

source

fn set_cursor_visible(&self, visible: bool) -> Result<()>

Modifies the cursor’s visibility.

If false, this will hide the cursor. If true, this will show the cursor.

source

fn set_cursor_icon(&self, icon: CursorIcon) -> Result<()>

source

fn set_cursor_position<Pos: Into<Position>>(&self, position: Pos) -> Result<()>

Changes the position of the cursor in window coordinates.

source

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

Ignores the window cursor events.

source

fn start_dragging(&self) -> Result<()>

Starts dragging the window.

source

fn eval_script<S: Into<String>>(&self, script: S) -> Result<()>

Executes javascript on the window this Dispatch represents.

source

fn update_menu_item(&self, id: u16, update: MenuUpdate) -> Result<()>

Applies the specified update to the menu item associated with the given id.

Object Safety§

This trait is not object safe.

Implementors§