pub struct Window<R: Runtime = Wry> { /* private fields */ }wry only.Expand description
A window managed by Tauri.
This type also implements Manager which allows you to manage other windows attached to
the same application.
Implementations§
Source§impl<R: Runtime> Window<R>
Base window functions.
impl<R: Runtime> Window<R>
Base window functions.
Sourcepub fn builder<M: Manager<R>, L: Into<String>>(
manager: &M,
label: L,
) -> WindowBuilder<'_, R, M>
Available on crate feature unstable only.
pub fn builder<M: Manager<R>, L: Into<String>>( manager: &M, label: L, ) -> WindowBuilder<'_, R, M>
unstable only.Initializes a window builder with the given window label.
Data URLs are only supported with the webview-data-url feature flag.
Sourcepub fn add_child<P: Into<Position>, S: Into<Size>>(
&self,
webview_builder: WebviewBuilder<R>,
position: P,
size: S,
) -> Result<Webview<R>>
Available on desktop and crate feature unstable only.
pub fn add_child<P: Into<Position>, S: Into<Size>>( &self, webview_builder: WebviewBuilder<R>, position: P, size: S, ) -> Result<Webview<R>>
desktop and crate feature unstable only.Adds a new webview as a child of this window.
Sourcepub fn run_on_main_thread<F: FnOnce() + Send + 'static>(
&self,
f: F,
) -> Result<()>
pub fn run_on_main_thread<F: FnOnce() + Send + 'static>( &self, f: F, ) -> Result<()>
Runs the given closure on the main thread.
Sourcepub fn on_window_event<F: Fn(&WindowEvent) + Send + 'static>(&self, f: F)
pub fn on_window_event<F: Fn(&WindowEvent) + Send + 'static>(&self, f: F)
Registers a window event listener.
Source§impl<R: Runtime> Window<R>
Menu APIs
impl<R: Runtime> Window<R>
Menu APIs
Available on desktop only.
desktop only.Registers a global menu event listener.
Note that this handler is called for any menu event, whether it is coming from this window, another window or from the tray icon menu.
Also note that this handler will not be called if the window used to register it was closed.
§Examples
use tauri::menu::{Menu, Submenu, MenuItem};
tauri::Builder::default()
.setup(|app| {
let handle = app.handle();
let save_menu_item = MenuItem::new(handle, "Save", true, None::<&str>)?;
let menu = Menu::with_items(handle, &[
&Submenu::with_items(handle, "File", true, &[
&save_menu_item,
])?,
])?;
let window = tauri::window::WindowBuilder::new(app, "editor")
.menu(menu)
.build()
.unwrap();
window.on_menu_event(move |window, event| {
if event.id == save_menu_item.id() {
// save menu item
}
});
Ok(())
});Available on desktop only.
desktop only.Returns this window menu .
Available on desktop only.
desktop only.Sets the window menu and returns the previous one.
§Platform-specific:
- macOS: Unsupported. The menu on macOS is app-wide and not specific to one
window, if you need to set it, use
AppHandle::set_menuinstead.
Available on desktop only.
desktop only.Removes the window menu and returns it.
§Platform-specific:
- macOS: Unsupported. The menu on macOS is app-wide and not specific to one
window, if you need to remove it, use
AppHandle::remove_menuinstead.
Available on desktop only.
desktop only.Hides the window menu.
Available on desktop only.
desktop only.Shows the window menu.
Available on desktop only.
desktop only.Shows the window menu.
Available on desktop only.
desktop only.Shows the specified menu as a context menu at the cursor position.
Available on desktop only.
desktop only.Shows the specified menu as a context menu at the specified position.
The position is relative to the window’s top-left corner.
Source§impl<R: Runtime> Window<R>
Window getters.
impl<R: Runtime> Window<R>
Window getters.
Sourcepub fn scale_factor(&self) -> Result<f64>
pub fn scale_factor(&self) -> Result<f64>
Returns the scale factor that can be used to map logical pixels to physical pixels, and vice versa.
Sourcepub fn inner_position(&self) -> Result<PhysicalPosition<i32>>
pub 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.
Sourcepub fn outer_position(&self) -> Result<PhysicalPosition<i32>>
pub 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.
Sourcepub fn inner_size(&self) -> Result<PhysicalSize<u32>>
pub 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.
Sourcepub fn outer_size(&self) -> Result<PhysicalSize<u32>>
pub 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.
Sourcepub fn is_fullscreen(&self) -> Result<bool>
pub fn is_fullscreen(&self) -> Result<bool>
Gets the window’s current fullscreen state.
Sourcepub fn is_minimized(&self) -> Result<bool>
pub fn is_minimized(&self) -> Result<bool>
Gets the window’s current minimized state.
Sourcepub fn is_maximized(&self) -> Result<bool>
pub fn is_maximized(&self) -> Result<bool>
Gets the window’s current maximized state.
Sourcepub fn is_focused(&self) -> Result<bool>
pub fn is_focused(&self) -> Result<bool>
Gets the window’s current focus state.
Sourcepub fn is_decorated(&self) -> Result<bool>
pub fn is_decorated(&self) -> Result<bool>
Gets the window’s current decoration state.
Sourcepub fn is_resizable(&self) -> Result<bool>
pub fn is_resizable(&self) -> Result<bool>
Gets the window’s current resizable state.
Sourcepub fn is_enabled(&self) -> Result<bool>
pub fn is_enabled(&self) -> Result<bool>
Whether the window is enabled or disabled.
Sourcepub fn is_always_on_top(&self) -> Result<bool>
pub fn is_always_on_top(&self) -> Result<bool>
Determines if this window should always be on top of other windows.
§Platform-specific
- iOS / Android: Unsupported.
Sourcepub fn is_maximizable(&self) -> Result<bool>
pub fn is_maximizable(&self) -> Result<bool>
Gets the window’s native maximize button state
§Platform-specific
- Linux / iOS / Android: Unsupported.
Sourcepub fn is_minimizable(&self) -> Result<bool>
pub fn is_minimizable(&self) -> Result<bool>
Gets the window’s native minimize button state
§Platform-specific
- Linux / iOS / Android: Unsupported.
Sourcepub fn is_closable(&self) -> Result<bool>
pub fn is_closable(&self) -> Result<bool>
Sourcepub fn is_visible(&self) -> Result<bool>
pub fn is_visible(&self) -> Result<bool>
Gets the window’s current visibility state.
Sourcepub fn current_monitor(&self) -> Result<Option<Monitor>>
pub 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.
Sourcepub fn monitor_from_point(&self, x: f64, y: f64) -> Result<Option<Monitor>>
pub fn monitor_from_point(&self, x: f64, y: f64) -> Result<Option<Monitor>>
Returns the monitor that contains the given point.
Sourcepub fn primary_monitor(&self) -> Result<Option<Monitor>>
pub 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.
Sourcepub fn available_monitors(&self) -> Result<Vec<Monitor>>
pub fn available_monitors(&self) -> Result<Vec<Monitor>>
Returns the list of all the monitors available on the system.
Sourcepub fn gtk_window(&self) -> Result<ApplicationWindow>
Available on Linux or DragonFly BSD or FreeBSD or NetBSD or OpenBSD only.
pub fn gtk_window(&self) -> Result<ApplicationWindow>
Returns the ApplicationWindow from gtk crate that is used by this window.
Note that this type can only be used on the main thread.
Sourcepub fn default_vbox(&self) -> Result<Box>
Available on Linux or DragonFly BSD or FreeBSD or NetBSD or OpenBSD only.
pub fn default_vbox(&self) -> Result<Box>
Returns the vertical gtk::Box that is added by default as the sole child of this window.
Note that this type can only be used on the main thread.
Source§impl<R: Runtime> Window<R>
Desktop window getters.
impl<R: Runtime> Window<R>
Desktop window getters.
Sourcepub fn cursor_position(&self) -> Result<PhysicalPosition<f64>>
Available on desktop only.
pub fn cursor_position(&self) -> Result<PhysicalPosition<f64>>
desktop only.Get the cursor position relative to the top-left hand corner of the desktop.
Note that the top-left hand corner of the desktop is not necessarily the same as the screen. If the user uses a desktop with multiple monitors, the top-left hand corner of the desktop is the top-left hand corner of the main monitor on Windows and macOS or the top-left of the leftmost monitor on X11.
The coordinates can be negative if the top-left hand corner of the window is outside of the visible screen region.
Source§impl<R: Runtime> Window<R>
Desktop window setters and actions.
impl<R: Runtime> Window<R>
Desktop window setters and actions.
Sourcepub fn request_user_attention(
&self,
request_type: Option<UserAttentionType>,
) -> Result<()>
Available on desktop only.
pub fn request_user_attention( &self, request_type: Option<UserAttentionType>, ) -> Result<()>
desktop only.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:
Nonehas no effect. - Linux: Urgency levels have the same effect.
Sourcepub fn set_resizable(&self, resizable: bool) -> Result<()>
Available on desktop only.
pub fn set_resizable(&self, resizable: bool) -> Result<()>
desktop only.Determines if this window should be resizable. When resizable is set to false, native window’s maximize button is automatically disabled.
Sourcepub fn set_maximizable(&self, maximizable: bool) -> Result<()>
Available on desktop only.
pub fn set_maximizable(&self, maximizable: bool) -> Result<()>
desktop only.Determines if this window’s native maximize button should be enabled. If resizable is set to false, this setting is ignored.
§Platform-specific
- macOS: Disables the “zoom” button in the window titlebar, which is also used to enter fullscreen mode.
- Linux / iOS / Android: Unsupported.
Sourcepub fn set_minimizable(&self, minimizable: bool) -> Result<()>
Available on desktop only.
pub fn set_minimizable(&self, minimizable: bool) -> Result<()>
desktop only.Determines if this window’s native minimize button should be enabled.
§Platform-specific
- Linux / iOS / Android: Unsupported.
Sourcepub fn set_closable(&self, closable: bool) -> Result<()>
Available on desktop only.
pub fn set_closable(&self, closable: bool) -> Result<()>
desktop only.Determines if this window’s native close button should be enabled.
§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.
Sourcepub fn set_title(&self, title: &str) -> Result<()>
Available on desktop only.
pub fn set_title(&self, title: &str) -> Result<()>
desktop only.Set this window’s title.
Sourcepub fn set_enabled(&self, enabled: bool) -> Result<()>
Available on desktop only.
pub fn set_enabled(&self, enabled: bool) -> Result<()>
desktop only.Enable or disable the window.
Sourcepub fn unmaximize(&self) -> Result<()>
Available on desktop only.
pub fn unmaximize(&self) -> Result<()>
desktop only.Un-maximizes this window.
Sourcepub fn unminimize(&self) -> Result<()>
Available on desktop only.
pub fn unminimize(&self) -> Result<()>
desktop only.Un-minimizes this window.
Sourcepub fn close(&self) -> Result<()>
Available on desktop only.
pub fn close(&self) -> Result<()>
desktop only.Closes this window. It emits [crate::RunEvent::CloseRequested] first like a user-initiated close request so you can intercept it.
Sourcepub fn destroy(&self) -> Result<()>
Available on desktop only.
pub fn destroy(&self) -> Result<()>
desktop only.Destroys this window. Similar to Self::close but does not emit any events and force close the window instead.
Sourcepub fn set_decorations(&self, decorations: bool) -> Result<()>
Available on desktop only.
pub fn set_decorations(&self, decorations: bool) -> Result<()>
desktop only.Determines if this window should be decorated.
Sourcepub fn set_shadow(&self, enable: bool) -> Result<()>
Available on desktop only.
pub fn set_shadow(&self, enable: bool) -> Result<()>
desktop only.Determines if this window should have shadow.
§Platform-specific
- Windows:
falsehas no effect on decorated window, shadow are always ON.truewill make undecorated window have a 1px white border, and on Windows 11, it will have a rounded corners.
- Linux: Unsupported.
Sourcepub fn set_effects<E: Into<Option<WindowEffectsConfig>>>(
&self,
effects: E,
) -> Result<()>
Available on desktop only.
pub fn set_effects<E: Into<Option<WindowEffectsConfig>>>( &self, effects: E, ) -> Result<()>
desktop only.Sets window effects, pass None to clear any effects applied if possible.
Requires the window to be transparent.
See EffectsBuilder for a convenient builder for WindowEffectsConfig.
use tauri::{Manager, window::{Color, Effect, EffectState, EffectsBuilder}};
tauri::Builder::default()
.setup(|app| {
let window = app.get_window("main").unwrap();
window.set_effects(
EffectsBuilder::new()
.effect(Effect::Popover)
.state(EffectState::Active)
.radius(5.)
.color(Color(0, 0, 0, 255))
.build(),
)?;
Ok(())
});§Platform-specific:
- Windows: If using decorations or shadows, you may want to try this workaround https://github.com/tauri-apps/tao/issues/72#issuecomment-975607891
- Linux: Unsupported
Sourcepub fn set_always_on_bottom(&self, always_on_bottom: bool) -> Result<()>
Available on desktop only.
pub fn set_always_on_bottom(&self, always_on_bottom: bool) -> Result<()>
desktop only.Determines if this window should always be below other windows.
Sourcepub fn set_always_on_top(&self, always_on_top: bool) -> Result<()>
Available on desktop only.
pub fn set_always_on_top(&self, always_on_top: bool) -> Result<()>
desktop only.Determines if this window should always be on top of other windows.
Sourcepub fn set_visible_on_all_workspaces(
&self,
visible_on_all_workspaces: bool,
) -> Result<()>
Available on desktop only.
pub fn set_visible_on_all_workspaces( &self, visible_on_all_workspaces: bool, ) -> Result<()>
desktop only.Sets whether the window should be visible on all workspaces or virtual desktops.
§Platform-specific
- Windows / iOS / Android: Unsupported.
Sourcepub fn set_background_color(&self, color: Option<Color>) -> Result<()>
Available on desktop only.
pub fn set_background_color(&self, color: Option<Color>) -> Result<()>
desktop only.Sets the window background color.
§Platform-specific:
- Windows: alpha channel is ignored.
- iOS / Android: Unsupported.
Sourcepub fn set_content_protected(&self, protected: bool) -> Result<()>
Available on desktop only.
pub fn set_content_protected(&self, protected: bool) -> Result<()>
desktop only.Prevents the window contents from being captured by other apps.
Sourcepub fn set_size<S: Into<Size>>(&self, size: S) -> Result<()>
Available on desktop only.
pub fn set_size<S: Into<Size>>(&self, size: S) -> Result<()>
desktop only.Resizes this window.
Sourcepub fn set_min_size<S: Into<Size>>(&self, size: Option<S>) -> Result<()>
Available on desktop only.
pub fn set_min_size<S: Into<Size>>(&self, size: Option<S>) -> Result<()>
desktop only.Sets this window’s minimum inner size.
Sourcepub fn set_max_size<S: Into<Size>>(&self, size: Option<S>) -> Result<()>
Available on desktop only.
pub fn set_max_size<S: Into<Size>>(&self, size: Option<S>) -> Result<()>
desktop only.Sets this window’s maximum inner size.
Sourcepub fn set_size_constraints(
&self,
constraints: WindowSizeConstraints,
) -> Result<()>
Available on desktop only.
pub fn set_size_constraints( &self, constraints: WindowSizeConstraints, ) -> Result<()>
desktop only.Sets this window’s minimum inner width.
Sourcepub fn set_position<Pos: Into<Position>>(&self, position: Pos) -> Result<()>
Available on desktop only.
pub fn set_position<Pos: Into<Position>>(&self, position: Pos) -> Result<()>
desktop only.Sets this window’s position.
Sourcepub fn set_fullscreen(&self, fullscreen: bool) -> Result<()>
Available on desktop only.
pub fn set_fullscreen(&self, fullscreen: bool) -> Result<()>
desktop only.Determines if this window should be fullscreen.
Sourcepub fn set_simple_fullscreen(&self, fullscreen: bool) -> Result<()>
Available on desktop and non-macOS only.
pub fn set_simple_fullscreen(&self, fullscreen: bool) -> Result<()>
desktop and non-macOS only.On macOS, Toggles a fullscreen mode that doesn’t require a new macOS space. Returns a boolean indicating whether the transition was successful (this won’t work if the window was already in the native fullscreen). This is how fullscreen used to work on macOS in versions before Lion. And allows the user to have a fullscreen window without using another space or taking control over the entire monitor.
On other platforms, this is the same as Window.
Sourcepub fn set_focus(&self) -> Result<()>
Available on desktop only.
pub fn set_focus(&self) -> Result<()>
desktop only.Bring the window to front and focus.
Sourcepub fn set_focusable(&self, focusable: bool) -> Result<()>
Available on desktop only.
pub fn set_focusable(&self, focusable: bool) -> Result<()>
desktop only.Sets whether the window can be focused.
§Platform-specific
- macOS: If the window is already focused, it is not possible to unfocus it after calling
set_focusable(false). In this case, you might consider callingWindow::set_focusbut it will move the window to the back i.e. at the bottom in terms of z-order.
Sourcepub fn set_icon(&self, icon: Image<'_>) -> Result<()>
Available on desktop only.
pub fn set_icon(&self, icon: Image<'_>) -> Result<()>
desktop only.Sets this window’ icon.
Sourcepub fn set_skip_taskbar(&self, skip: bool) -> Result<()>
Available on desktop only.
pub fn set_skip_taskbar(&self, skip: bool) -> Result<()>
desktop only.Sourcepub fn set_cursor_grab(&self, grab: bool) -> Result<()>
Available on desktop only.
pub fn set_cursor_grab(&self, grab: bool) -> Result<()>
desktop only.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.
Sourcepub fn set_cursor_visible(&self, visible: bool) -> Result<()>
Available on desktop only.
pub fn set_cursor_visible(&self, visible: bool) -> Result<()>
desktop only.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.
Sourcepub fn set_cursor_icon(&self, icon: CursorIcon) -> Result<()>
Available on desktop only.
pub fn set_cursor_icon(&self, icon: CursorIcon) -> Result<()>
desktop only.Modifies the cursor icon of the window.
Sourcepub fn set_cursor_position<Pos: Into<Position>>(
&self,
position: Pos,
) -> Result<()>
Available on desktop only.
pub fn set_cursor_position<Pos: Into<Position>>( &self, position: Pos, ) -> Result<()>
desktop only.Changes the position of the cursor in window coordinates.
Sourcepub fn set_ignore_cursor_events(&self, ignore: bool) -> Result<()>
Available on desktop only.
pub fn set_ignore_cursor_events(&self, ignore: bool) -> Result<()>
desktop only.Ignores the window cursor events.
Sourcepub fn start_dragging(&self) -> Result<()>
Available on desktop only.
pub fn start_dragging(&self) -> Result<()>
desktop only.Starts dragging the window.
Sourcepub fn start_resize_dragging(&self, direction: ResizeDirection) -> Result<()>
Available on desktop only.
pub fn start_resize_dragging(&self, direction: ResizeDirection) -> Result<()>
desktop only.Starts resize-dragging the window.
Sourcepub fn set_badge_count(&self, count: Option<i64>) -> Result<()>
Available on desktop only.
pub fn set_badge_count(&self, count: Option<i64>) -> Result<()>
desktop only.Sets the taskbar badge count. Using 0 or None will remove the badge
§Platform-specific
- Windows: Unsupported, use [
Window::set_overlay_icon] instead. - iOS: iOS expects i32, the value will be clamped to i32::MIN, i32::MAX.
- Android: Unsupported.
Sourcepub fn set_progress_bar(&self, progress_state: ProgressBarState) -> Result<()>
Available on desktop only.
pub fn set_progress_bar(&self, progress_state: ProgressBarState) -> Result<()>
desktop only.Sets the taskbar progress state.
§Platform-specific
- Linux / macOS: Progress bar is app-wide and not specific to this window.
- Linux: Only supported desktop environments with
libunity(e.g. GNOME). - iOS / Android: Unsupported.
Sourcepub fn set_title_bar_style(&self, style: TitleBarStyle) -> Result<()>
Available on desktop only.
pub fn set_title_bar_style(&self, style: TitleBarStyle) -> Result<()>
desktop only.Sets the title bar style. macOS only.
Trait Implementations§
Source§impl<'de, R: Runtime> CommandArg<'de, R> for Window<R>
impl<'de, R: Runtime> CommandArg<'de, R> for Window<R>
Source§fn from_command(command: CommandItem<'de, R>) -> Result<Self, InvokeError>
fn from_command(command: CommandItem<'de, R>) -> Result<Self, InvokeError>
Grabs the Window from the CommandItem. This will never fail.
Source§impl<R: Runtime> Emitter<R> for Window<R>
impl<R: Runtime> Emitter<R> for Window<R>
Source§fn emit_str(&self, event: &str, payload: String) -> Result<()>
fn emit_str(&self, event: &str, payload: String) -> Result<()>
Emitter::emit but the payload is json serialized.Source§fn emit_str_to<I>(&self, target: I, event: &str, payload: String) -> Result<()>where
I: Into<EventTarget>,
fn emit_str_to<I>(&self, target: I, event: &str, payload: String) -> Result<()>where
I: Into<EventTarget>,
Emitter::emit_to but the payload is json serialized.Source§fn emit_str_filter<F>(
&self,
event: &str,
payload: String,
filter: F,
) -> Result<()>
fn emit_str_filter<F>( &self, event: &str, payload: String, filter: F, ) -> Result<()>
Emitter::emit_filter but the payload is json serialized.Source§impl<R: Runtime> FunctionArg for Window<R>
Available on crate feature specta only.
impl<R: Runtime> FunctionArg for Window<R>
specta only.Source§impl<R: Runtime> HasDisplayHandle for Window<R>
impl<R: Runtime> HasDisplayHandle for Window<R>
Source§fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError>
fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError>
Source§impl<R: Runtime> HasWindowHandle for Window<R>
impl<R: Runtime> HasWindowHandle for Window<R>
Source§fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError>
fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError>
Source§impl<R: Runtime> Listener<R> for Window<R>
impl<R: Runtime> Listener<R> for Window<R>
Source§fn listen<F>(&self, event: impl Into<String>, handler: F) -> EventId
fn listen<F>(&self, event: impl Into<String>, handler: F) -> EventId
Listen to an event on this window.
§Examples
use tauri::{Manager, Listener};
tauri::Builder::default()
.setup(|app| {
let window = app.get_window("main").unwrap();
window.listen("component-loaded", move |event| {
println!("window just loaded a component");
});
Ok(())
});Source§fn once<F>(&self, event: impl Into<String>, handler: F) -> EventId
fn once<F>(&self, event: impl Into<String>, handler: F) -> EventId
Listen to an event on this window only once.
See Self::listen for more information.
Source§fn unlisten(&self, id: EventId)
fn unlisten(&self, id: EventId)
Unlisten to an event on this window.
§Examples
use tauri::{Manager, Listener};
tauri::Builder::default()
.setup(|app| {
let window = app.get_window("main").unwrap();
let window_ = window.clone();
let handler = window.listen("component-loaded", move |event| {
println!("window just loaded a component");
// we no longer need to listen to the event
// we also could have used `window.once` instead
window_.unlisten(event.id());
});
// stop listening to the event when you do not need it anymore
window.unlisten(handler);
Ok(())
});Source§impl<R: Runtime> Manager<R> for Window<R>
impl<R: Runtime> Manager<R> for Window<R>
Source§fn resources_table(&self) -> MutexGuard<'_, ResourceTable>
fn resources_table(&self) -> MutexGuard<'_, ResourceTable>
Source§fn app_handle(&self) -> &AppHandle<R>
fn app_handle(&self) -> &AppHandle<R>
Source§fn package_info(&self) -> &PackageInfo
fn package_info(&self) -> &PackageInfo
PackageInfo the manager was created with.Source§fn get_window(&self, label: &str) -> Option<Window<R>>
fn get_window(&self, label: &str) -> Option<Window<R>>
unstable only.Source§fn get_focused_window(&self) -> Option<Window<R>>
fn get_focused_window(&self) -> Option<Window<R>>
unstable only.None if there is not any focused window.Source§fn windows(&self) -> HashMap<String, Window<R>>
fn windows(&self) -> HashMap<String, Window<R>>
unstable only.Source§fn get_webview(&self, label: &str) -> Option<Webview<R>>
fn get_webview(&self, label: &str) -> Option<Webview<R>>
unstable only.Source§fn webviews(&self) -> HashMap<String, Webview<R>>
fn webviews(&self) -> HashMap<String, Webview<R>>
unstable only.Source§fn get_webview_window(&self, label: &str) -> Option<WebviewWindow<R>>
fn get_webview_window(&self, label: &str) -> Option<WebviewWindow<R>>
Source§fn webview_windows(&self) -> HashMap<String, WebviewWindow<R>>
fn webview_windows(&self) -> HashMap<String, WebviewWindow<R>>
Source§fn manage<T>(&self, state: T) -> bool
fn manage<T>(&self, state: T) -> bool
state to the state managed by the application. Read moreSource§fn unmanage<T>(&self) -> Option<T>
fn unmanage<T>(&self) -> Option<T>
Source§fn try_state<T>(&self) -> Option<State<'_, T>>
fn try_state<T>(&self) -> Option<State<'_, T>>
T. Read moreSource§fn asset_protocol_scope(&self) -> Scope
fn asset_protocol_scope(&self) -> Scope
protocol-asset only.Source§fn path(&self) -> &PathResolver<R>
fn path(&self) -> &PathResolver<R>
Source§fn add_capability(&self, capability: impl RuntimeCapability) -> Result<()>
fn add_capability(&self, capability: impl RuntimeCapability) -> Result<()>
dynamic-acl only.impl<R: Runtime> Eq for Window<R>
Auto Trait Implementations§
impl<R> Freeze for Window<R>where
<R as Runtime<EventLoopMessage>>::WindowDispatcher: Freeze,
<R as Runtime<EventLoopMessage>>::Handle: Freeze,
<R as Runtime<EventLoopMessage>>::WebviewDispatcher: Freeze,
impl<R = Wry<EventLoopMessage>> !RefUnwindSafe for Window<R>
impl<R> Send for Window<R>
impl<R> Sync for Window<R>
impl<R> Unpin for Window<R>where
<R as Runtime<EventLoopMessage>>::WindowDispatcher: Unpin,
<R as Runtime<EventLoopMessage>>::Handle: Unpin,
<R as Runtime<EventLoopMessage>>::WebviewDispatcher: Unpin,
impl<R = Wry<EventLoopMessage>> !UnwindSafe for Window<R>
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§impl<T> HasRawDisplayHandle for Twhere
T: HasDisplayHandle + ?Sized,
impl<T> HasRawDisplayHandle for Twhere
T: HasDisplayHandle + ?Sized,
Source§fn raw_display_handle(&self) -> Result<RawDisplayHandle, HandleError>
fn raw_display_handle(&self) -> Result<RawDisplayHandle, HandleError>
HasDisplayHandle insteadSource§impl<T> HasRawWindowHandle for Twhere
T: HasWindowHandle + ?Sized,
impl<T> HasRawWindowHandle for Twhere
T: HasWindowHandle + ?Sized,
Source§fn raw_window_handle(&self) -> Result<RawWindowHandle, HandleError>
fn raw_window_handle(&self) -> Result<RawWindowHandle, HandleError>
HasWindowHandle instead