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
external object Companion

Properties

Link copied to clipboard
open external 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

Local event listeners.

Functions

Link copied to clipboard
external fun <T> _handleTauriEvent(event: String, handler: EventCallback<T>): Boolean
Link copied to clipboard
external fun activityName(): Promise<String>
Link copied to clipboard
external fun center(): Promise<Void>

Centers the window.

Link copied to clipboard
external fun clearEffects(): Promise<Void>

Clear any applied effects if possible.

Link copied to clipboard
external fun close(): Promise<Void>

Closes the window.

Link copied to clipboard
external fun destroy(): Promise<Void>

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

Link copied to clipboard
external fun <T> emit(event: String, payload: T = definedExternally): Promise<Void>

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

Link copied to clipboard
external fun <T> emitTo(target: EventTarget, event: String, payload: T = definedExternally): Promise<Void>
external fun <T> emitTo(target: String, event: String, payload: T = definedExternally): Promise<Void>

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

Link copied to clipboard
external fun hide(): Promise<Void>

Sets the window visibility to false.

Link copied to clipboard

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
external fun innerSize(): Promise<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
external fun isAlwaysOnTop(): Promise<Boolean>

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

Link copied to clipboard
external fun isClosable(): Promise<Boolean>

Gets the window's native close button state.

Link copied to clipboard
external fun isDecorated(): Promise<Boolean>

Gets the window's current decorated state.

Link copied to clipboard
external fun isEnabled(): Promise<Boolean>

Whether the window is enabled or disabled.

Link copied to clipboard
external fun isFocused(): Promise<Boolean>

Gets the window's current focus state.

Link copied to clipboard
external fun isFullscreen(): Promise<Boolean>

Gets the window's current fullscreen state.

Link copied to clipboard
external fun isMaximizable(): Promise<Boolean>

Gets the window's native maximize button state.

Link copied to clipboard
external fun isMaximized(): Promise<Boolean>

Gets the window's current maximized state.

Link copied to clipboard
external fun isMinimizable(): Promise<Boolean>

Gets the window's native minimize button state.

Link copied to clipboard
external fun isMinimized(): Promise<Boolean>

Gets the window's current minimized state.

Link copied to clipboard
external fun isResizable(): Promise<Boolean>

Gets the window's current resizable state.

Link copied to clipboard
external fun isVisible(): Promise<Boolean>

Gets the window's current visible state.

Link copied to clipboard
open external fun <T> listen(event: EventName, handler: EventCallback<T>): Promise<UnlistenFn>

Listen to an emitted event on this window.

Link copied to clipboard
external fun maximize(): Promise<Void>

Maximizes the window.

Link copied to clipboard
external fun minimize(): Promise<Void>

Minimizes the window.

Link copied to clipboard
open external fun <T> once(event: EventName, handler: EventCallback<T>): Promise<UnlistenFn>

Listen to an emitted event on this window only once.

Link copied to clipboard
external fun onCloseRequested(handler: (event: CloseRequestedEvent) -> Any): Promise<UnlistenFn>

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

Link copied to clipboard

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

Listen to window focus change.

Link copied to clipboard

Listen to window move.

Link copied to clipboard

Listen to window resize.

Link copied to clipboard

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

Listen to the system theme change.

Link copied to clipboard

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
external fun outerSize(): Promise<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
external fun requestUserAttention(requestType: UserAttentionType?): Promise<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
external fun scaleFactor(): Promise<Double>

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

Link copied to clipboard
external fun sceneIdentifier(): Promise<String>
Link copied to clipboard
external fun setAlwaysOnBottom(alwaysOnBottom: Boolean): Promise<Void>

Whether the window should always be below other windows.

Link copied to clipboard
external fun setAlwaysOnTop(alwaysOnTop: Boolean): Promise<Void>

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

Link copied to clipboard
open external fun setBackgroundColor(color: Color): Promise<Void>

Sets the window background color.

Link copied to clipboard
external fun setBadgeCount(count: Double = definedExternally): Promise<Void>

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

Link copied to clipboard
external fun setBadgeLabel(label: String = definedExternally): Promise<Void>

Sets the badge cont macOS only.

Link copied to clipboard
external fun setClosable(closable: Boolean): Promise<Void>

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

Link copied to clipboard
external fun setContentProtected(protected_: Boolean): Promise<Void>

Prevents the window contents from being captured by other apps.

Link copied to clipboard
external fun setCursorGrab(grab: Boolean): Promise<Void>

Grabs the cursor, preventing it from leaving the window.

Link copied to clipboard
external fun setCursorIcon(icon: CursorIcon): Promise<Void>

Modifies the cursor icon of the window.

Link copied to clipboard
external fun setCursorPosition(position: LogicalPosition): Promise<Void>
external fun setCursorPosition(position: Position): Promise<Void>

Changes the position of the cursor in window coordinates.

Link copied to clipboard
external fun setCursorVisible(visible: Boolean): Promise<Void>

Modifies the cursor's visibility.

Link copied to clipboard
external fun setDecorations(decorations: Boolean): Promise<Void>

Whether the window should have borders and bars.

Link copied to clipboard
external fun setEffects(effects: Effects): Promise<Void>

Set window effects.

Link copied to clipboard
external fun setEnabled(enabled: Boolean): Promise<Void>

Enable or disable the window.

Link copied to clipboard
external fun setFocus(): Promise<Void>

Bring the window to front and focus.

Link copied to clipboard
external fun setFocusable(focusable: Boolean): Promise<Void>

Sets whether the window can be focused.

Link copied to clipboard
external fun setFullscreen(fullscreen: Boolean): Promise<Void>

Sets the window fullscreen state.

Link copied to clipboard
external fun setIcon(icon: ArrayBuffer): Promise<Void>
external fun setIcon(icon: Uint8Array<*>): Promise<Void>
external fun setIcon(icon: ReadonlyArray<Double>): Promise<Void>
external fun setIcon(icon: String): Promise<Void>
external fun setIcon(icon: Image): Promise<Void>

Sets the window icon.

Link copied to clipboard
external fun setIgnoreCursorEvents(ignore: Boolean): Promise<Void>

Changes the cursor events behavior.

Link copied to clipboard
external fun setMaximizable(maximizable: Boolean): Promise<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
external fun setMaxSize(size: LogicalSize?): Promise<Void>
external fun setMaxSize(size: PhysicalSize?): Promise<Void>
external fun setMaxSize(size: Size?): Promise<Void>

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

Link copied to clipboard
external fun setMinimizable(minimizable: Boolean): Promise<Void>

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

Link copied to clipboard
external fun setMinSize(size: LogicalSize?): Promise<Void>
external fun setMinSize(size: PhysicalSize?): Promise<Void>
external fun setMinSize(size: Size?): Promise<Void>

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

Link copied to clipboard
external fun setOverlayIcon(): Promise<Void>
external fun setOverlayIcon(icon: ArrayBuffer = definedExternally): Promise<Void>
external fun setOverlayIcon(icon: Uint8Array<*> = definedExternally): Promise<Void>
external fun setOverlayIcon(icon: ReadonlyArray<Double> = definedExternally): Promise<Void>
external fun setOverlayIcon(icon: String = definedExternally): Promise<Void>
external fun setOverlayIcon(icon: Image = definedExternally): Promise<Void>

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

Link copied to clipboard
external fun setPosition(position: LogicalPosition): Promise<Void>
external fun setPosition(position: PhysicalPosition): Promise<Void>
external fun setPosition(position: Position): Promise<Void>

Sets the window outer position.

Link copied to clipboard

Sets the taskbar progress state.

Link copied to clipboard
external fun setResizable(resizable: Boolean): Promise<Void>

Updates the window resizable flag.

Link copied to clipboard
external fun setShadow(enable: Boolean): Promise<Void>

Whether or not the window should have shadow.

Link copied to clipboard
external fun setSimpleFullscreen(fullscreen: Boolean): Promise<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
external fun setSize(size: LogicalSize): Promise<Void>
external fun setSize(size: PhysicalSize): Promise<Void>
external fun setSize(size: Size): Promise<Void>

Resizes the window with a new inner size.

Link copied to clipboard

Sets the window inner size constraints.

Link copied to clipboard
external fun setSkipTaskbar(skip: Boolean): Promise<Void>

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

Link copied to clipboard
external fun setTheme(theme: Theme? = definedExternally): Promise<Void>

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

Link copied to clipboard
external fun setTitle(title: String): Promise<Void>

Sets the window title.

Link copied to clipboard

Sets the title bar style. macOS only.

Link copied to clipboard

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

Link copied to clipboard
external fun show(): Promise<Void>

Sets the window visibility to true.

Link copied to clipboard
external fun startDragging(): Promise<Void>

Starts dragging the window.

Link copied to clipboard
external fun startResizeDragging(direction: ResizeDirection): Promise<Void>

Starts resize-dragging the window.

Link copied to clipboard
external fun theme(): Promise<Theme?>

Gets the window's current theme.

Link copied to clipboard
external fun title(): Promise<String>

Gets the window's current title.

Link copied to clipboard
external fun toggleMaximize(): Promise<Void>

Toggles the window maximized state.

Link copied to clipboard
external fun unmaximize(): Promise<Void>

Unmaximizes the window.

Link copied to clipboard
external fun unminimize(): Promise<Void>

Unminimizes the window.