Window

open external class Window(source)

Create new window or get a handle to an existing one.

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 _.

Since

2.0.0

Constructors

Link copied to clipboard
constructor(label: WindowLabel, options: WindowOptions = definedExternally)

Creates a new Window.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open var label: WindowLabel

The window label. It is a unique identifier for the window, can be used to reference it later.

Link copied to clipboard
open var listeners: ERROR CLASS: Symbol not found for js.objects.ReadonlyRecord<kotlin/String, ERROR CLASS: Symbol not found for js.array.ReadonlyArray<{tauri/apps/api/EventCallback<kotlin/Any?>=} kotlin/Function1<@R|kotlin/ParameterName|(name = String(event)) tauri/apps/api/Event<kotlin/Any?>, kotlin/Unit>>>

Local event listeners.

Functions

Link copied to clipboard
fun <T> _handleTauriEvent(event: String, handler: EventCallback<T>): Boolean
Link copied to clipboard
fun center(): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Centers the window.

Link copied to clipboard
fun clearEffects(): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Clear any applied effects if possible.

Link copied to clipboard
fun close(): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Closes the window.

Link copied to clipboard
fun destroy(): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Destroys the window. Behaves like {@link Window.close} but forces the window close instead of emitting a closeRequested event.

Link copied to clipboard
fun <T> emit(event: String, payload: T = definedExternally): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Emits an event to all {@link EventTarget|targets}.

Link copied to clipboard
fun <T> emitTo(target: EventTarget, event: String, payload: T = definedExternally): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun <T> emitTo(target: String, event: String, payload: T = definedExternally): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Emits an event to all {@link EventTarget|targets} matching the given target.

Link copied to clipboard
fun hide(): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets the window visibility to false.

Link copied to clipboard
fun innerPosition(): ERROR CLASS: Symbol not found for js.promise.Promise<tauri/apps/api/PhysicalPosition>

The position of the top-left hand corner of the window's client area relative to the top-left hand corner of the desktop.

Link copied to clipboard
fun innerSize(): ERROR CLASS: Symbol not found for js.promise.Promise<tauri/apps/api/PhysicalSize>

The physical size of the window's client area. The client area is the content of the window, excluding the title bar and borders.

Link copied to clipboard
fun isAlwaysOnTop(): ERROR CLASS: Symbol not found for js.promise.Promise<kotlin/Boolean>

Whether the window is configured to be always on top of other windows or not.

Link copied to clipboard
fun isClosable(): ERROR CLASS: Symbol not found for js.promise.Promise<kotlin/Boolean>

Gets the window's native close button state.

Link copied to clipboard
fun isDecorated(): ERROR CLASS: Symbol not found for js.promise.Promise<kotlin/Boolean>

Gets the window's current decorated state.

Link copied to clipboard
fun isEnabled(): ERROR CLASS: Symbol not found for js.promise.Promise<kotlin/Boolean>

Whether the window is enabled or disabled.

Link copied to clipboard
fun isFocused(): ERROR CLASS: Symbol not found for js.promise.Promise<kotlin/Boolean>

Gets the window's current focus state.

Link copied to clipboard
fun isFullscreen(): ERROR CLASS: Symbol not found for js.promise.Promise<kotlin/Boolean>

Gets the window's current fullscreen state.

Link copied to clipboard
fun isMaximizable(): ERROR CLASS: Symbol not found for js.promise.Promise<kotlin/Boolean>

Gets the window's native maximize button state.

Link copied to clipboard
fun isMaximized(): ERROR CLASS: Symbol not found for js.promise.Promise<kotlin/Boolean>

Gets the window's current maximized state.

Link copied to clipboard
fun isMinimizable(): ERROR CLASS: Symbol not found for js.promise.Promise<kotlin/Boolean>

Gets the window's native minimize button state.

Link copied to clipboard
fun isMinimized(): ERROR CLASS: Symbol not found for js.promise.Promise<kotlin/Boolean>

Gets the window's current minimized state.

Link copied to clipboard
fun isResizable(): ERROR CLASS: Symbol not found for js.promise.Promise<kotlin/Boolean>

Gets the window's current resizable state.

Link copied to clipboard
fun isVisible(): ERROR CLASS: Symbol not found for js.promise.Promise<kotlin/Boolean>

Gets the window's current visible state.

Link copied to clipboard
open fun <T> listen(event: EventName, handler: EventCallback<T>): ERROR CLASS: Symbol not found for js.promise.Promise<{tauri/apps/api/UnlistenFn=} kotlin/Function0<kotlin/Unit>>

Listen to an emitted event on this window.

Link copied to clipboard
fun maximize(): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Maximizes the window.

Link copied to clipboard
fun minimize(): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Minimizes the window.

Link copied to clipboard
open fun <T> once(event: EventName, handler: EventCallback<T>): ERROR CLASS: Symbol not found for js.promise.Promise<{tauri/apps/api/UnlistenFn=} kotlin/Function0<kotlin/Unit>>

Listen to an emitted event on this window only once.

Link copied to clipboard
fun onCloseRequested(handler: (event: CloseRequestedEvent) -> Any): ERROR CLASS: Symbol not found for js.promise.Promise<{tauri/apps/api/UnlistenFn=} kotlin/Function0<kotlin/Unit>>

Listen to window close requested. Emitted when the user requests to closes the window.

Link copied to clipboard
fun onDragDropEvent(handler: EventCallback<DragDropEvent>): ERROR CLASS: Symbol not found for js.promise.Promise<{tauri/apps/api/UnlistenFn=} kotlin/Function0<kotlin/Unit>>

Listen to a file drop event. The listener is triggered when the user hovers the selected files on the webview, drops the files or cancels the operation.

Link copied to clipboard
fun onFocusChanged(handler: EventCallback<Boolean>): ERROR CLASS: Symbol not found for js.promise.Promise<{tauri/apps/api/UnlistenFn=} kotlin/Function0<kotlin/Unit>>

Listen to window focus change.

Link copied to clipboard
fun onMoved(handler: EventCallback<PhysicalPosition>): ERROR CLASS: Symbol not found for js.promise.Promise<{tauri/apps/api/UnlistenFn=} kotlin/Function0<kotlin/Unit>>

Listen to window move.

Link copied to clipboard
fun onResized(handler: EventCallback<PhysicalSize>): ERROR CLASS: Symbol not found for js.promise.Promise<{tauri/apps/api/UnlistenFn=} kotlin/Function0<kotlin/Unit>>

Listen to window resize.

Link copied to clipboard
fun onScaleChanged(handler: EventCallback<ScaleFactorChanged>): ERROR CLASS: Symbol not found for js.promise.Promise<{tauri/apps/api/UnlistenFn=} kotlin/Function0<kotlin/Unit>>

Listen to window scale change. Emitted when the window's scale factor has changed. The following user actions can cause DPI changes:

Link copied to clipboard
fun onThemeChanged(handler: EventCallback<Theme>): ERROR CLASS: Symbol not found for js.promise.Promise<{tauri/apps/api/UnlistenFn=} kotlin/Function0<kotlin/Unit>>

Listen to the system theme change.

Link copied to clipboard
fun outerPosition(): ERROR CLASS: Symbol not found for js.promise.Promise<tauri/apps/api/PhysicalPosition>

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

Link copied to clipboard
fun outerSize(): ERROR CLASS: Symbol not found for js.promise.Promise<tauri/apps/api/PhysicalSize>

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.

Link copied to clipboard
fun requestUserAttention(requestType: UserAttentionType?): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

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.

Link copied to clipboard
fun scaleFactor(): ERROR CLASS: Symbol not found for js.promise.Promise<kotlin/Double>

The scale factor that can be used to map physical pixels to logical pixels.

Link copied to clipboard
fun setAlwaysOnBottom(alwaysOnBottom: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Whether the window should always be below other windows.

Link copied to clipboard
fun setAlwaysOnTop(alwaysOnTop: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Whether the window should always be on top of other windows.

Link copied to clipboard
open fun setBackgroundColor(color: Color): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets the window background color.

Link copied to clipboard
fun setBadgeCount(count: Double = definedExternally): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets the badge count. It is app wide and not specific to this window.

Link copied to clipboard
fun setBadgeLabel(label: String = definedExternally): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets the badge cont macOS only.

Link copied to clipboard
fun setClosable(closable: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets whether the window's native close button is enabled or not.

Link copied to clipboard
fun setContentProtected(protected_: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Prevents the window contents from being captured by other apps.

Link copied to clipboard
fun setCursorGrab(grab: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Grabs the cursor, preventing it from leaving the window.

Link copied to clipboard
fun setCursorIcon(icon: CursorIcon): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Modifies the cursor icon of the window.

Link copied to clipboard
fun setCursorPosition(position: LogicalPosition): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setCursorPosition(position: PhysicalPosition): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setCursorPosition(position: Position): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Changes the position of the cursor in window coordinates.

Link copied to clipboard
fun setCursorVisible(visible: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Modifies the cursor's visibility.

Link copied to clipboard
fun setDecorations(decorations: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Whether the window should have borders and bars.

Link copied to clipboard
fun setEffects(effects: Effects): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Set window effects.

Link copied to clipboard
fun setEnabled(enabled: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Enable or disable the window.

Link copied to clipboard
fun setFocus(): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Bring the window to front and focus.

Link copied to clipboard
fun setFocusable(focusable: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets whether the window can be focused.

Link copied to clipboard
fun setFullscreen(fullscreen: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets the window fullscreen state.

Link copied to clipboard
fun setIcon(icon: ERROR CLASS: Symbol not found for js.array.ReadonlyArray<kotlin/Double>): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setIcon(icon: ERROR CLASS: Symbol not found for js.buffer.ArrayBuffer): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setIcon(icon: ERROR CLASS: Symbol not found for js.typedarrays.Uint8Array<ERROR CLASS: Symbol not found for js.buffer.ArrayBuffer>): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setIcon(icon: String): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setIcon(icon: Image): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets the window icon.

Link copied to clipboard
fun setIgnoreCursorEvents(ignore: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Changes the cursor events behavior.

Link copied to clipboard
fun setMaximizable(maximizable: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets whether the window's native maximize button is enabled or not. If resizable is set to false, this setting is ignored.

Link copied to clipboard
fun setMaxSize(size: LogicalSize?): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setMaxSize(size: PhysicalSize?): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setMaxSize(size: Size?): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets the window maximum inner size. If the size argument is undefined, the constraint is unset.

Link copied to clipboard
fun setMinimizable(minimizable: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets whether the window's native minimize button is enabled or not.

Link copied to clipboard
fun setMinSize(size: LogicalSize?): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setMinSize(size: PhysicalSize?): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setMinSize(size: Size?): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets the window minimum inner size. If the size argument is not provided, the constraint is unset.

Link copied to clipboard
fun setOverlayIcon(): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setOverlayIcon(icon: ERROR CLASS: Symbol not found for js.array.ReadonlyArray<kotlin/Double> = definedExternally): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setOverlayIcon(icon: ERROR CLASS: Symbol not found for js.buffer.ArrayBuffer = definedExternally): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setOverlayIcon(icon: ERROR CLASS: Symbol not found for js.typedarrays.Uint8Array<ERROR CLASS: Symbol not found for js.buffer.ArrayBuffer> = definedExternally): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setOverlayIcon(icon: String = definedExternally): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setOverlayIcon(icon: Image = definedExternally): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets the overlay icon. Windows only The overlay icon can be set for every window.

Link copied to clipboard
fun setPosition(position: LogicalPosition): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setPosition(position: PhysicalPosition): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setPosition(position: Position): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets the window outer position.

Link copied to clipboard
fun setProgressBar(state: ProgressBarState): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets the taskbar progress state.

Link copied to clipboard
fun setResizable(resizable: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Updates the window resizable flag.

Link copied to clipboard
fun setShadow(enable: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Whether or not the window should have shadow.

Link copied to clipboard
fun setSimpleFullscreen(fullscreen: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

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.

Link copied to clipboard
fun setSize(size: LogicalSize): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setSize(size: PhysicalSize): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>
fun setSize(size: Size): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Resizes the window with a new inner size.

Link copied to clipboard
fun setSizeConstraints(constraints: WindowSizeConstraints?): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets the window inner size constraints.

Link copied to clipboard
fun setSkipTaskbar(skip: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Whether the window icon should be hidden from the taskbar or not.

Link copied to clipboard
fun setTheme(theme: Theme? = definedExternally): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Set window theme, pass in null or undefined to follow system theme

Link copied to clipboard
fun setTitle(title: String): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets the window title.

Link copied to clipboard
fun setTitleBarStyle(style: TitleBarStyle): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets the title bar style. macOS only.

Link copied to clipboard
fun setVisibleOnAllWorkspaces(visible: Boolean): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets whether the window should be visible on all workspaces or virtual desktops.

Link copied to clipboard
fun show(): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Sets the window visibility to true.

Link copied to clipboard
fun startDragging(): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Starts dragging the window.

Link copied to clipboard
fun startResizeDragging(direction: ResizeDirection): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Starts resize-dragging the window.

Link copied to clipboard
fun theme(): ERROR CLASS: Symbol not found for js.promise.Promise<tauri/apps/api/Theme?>

Gets the window's current theme.

Link copied to clipboard
fun title(): ERROR CLASS: Symbol not found for js.promise.Promise<kotlin/String>

Gets the window's current title.

Link copied to clipboard
fun toggleMaximize(): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Toggles the window maximized state.

Link copied to clipboard
fun unmaximize(): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Unmaximizes the window.

Link copied to clipboard
fun unminimize(): ERROR CLASS: Symbol not found for js.promise.Promise<ERROR CLASS: Symbol not found for js.core.Void>

Unminimizes the window.