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

Local event listeners.

Functions

Link copied to clipboard
fun <T> _handleTauriEvent(event: String, handler: EventCallback<T>): Boolean
Link copied to clipboard

Centers the window.

Link copied to clipboard

Clear any applied effects if possible.

Link copied to clipboard

Closes the window.

Link copied to clipboard

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): Promise<Void>

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

Link copied to clipboard
fun <T> emitTo(target: EventTarget, event: String, payload: T = definedExternally): Promise<Void>
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
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

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

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

Link copied to clipboard

Gets the window's native close button state.

Link copied to clipboard

Gets the window's current decorated state.

Link copied to clipboard

Whether the window is enabled or disabled.

Link copied to clipboard

Gets the window's current focus state.

Link copied to clipboard

Gets the window's current fullscreen state.

Link copied to clipboard

Gets the window's native maximize button state.

Link copied to clipboard

Gets the window's current maximized state.

Link copied to clipboard

Gets the window's native minimize button state.

Link copied to clipboard

Gets the window's current minimized state.

Link copied to clipboard

Gets the window's current resizable state.

Link copied to clipboard

Gets the window's current visible state.

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

Listen to an emitted event on this window.

Link copied to clipboard

Maximizes the window.

Link copied to clipboard

Minimizes the window.

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

Listen to an emitted event on this window only once.

Link copied to clipboard

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

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

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

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

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

Whether the window should always be below other windows.

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

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

Link copied to clipboard

Sets the window background color.

Link copied to clipboard
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
fun setBadgeLabel(label: String = definedExternally): Promise<Void>

Sets the badge cont macOS only.

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

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

Link copied to clipboard

Prevents the window contents from being captured by other apps.

Link copied to clipboard

Grabs the cursor, preventing it from leaving the window.

Link copied to clipboard

Modifies the cursor icon of the window.

Link copied to clipboard

Changes the position of the cursor in window coordinates.

Link copied to clipboard

Modifies the cursor's visibility.

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

Whether the window should have borders and bars.

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

Set window effects.

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

Enable or disable the window.

Link copied to clipboard

Bring the window to front and focus.

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

Sets whether the window can be focused.

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

Sets the window fullscreen state.

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

Sets the window icon.

Link copied to clipboard

Changes the cursor events behavior.

Link copied to clipboard
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
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
fun setMinimizable(minimizable: Boolean): Promise<Void>

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

Link copied to clipboard
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
fun setOverlayIcon(icon: ArrayBuffer = definedExternally): Promise<Void>
fun setOverlayIcon(icon: Uint8Array<*> = definedExternally): Promise<Void>
fun setOverlayIcon(icon: ReadonlyArray<Double> = definedExternally): Promise<Void>
fun setOverlayIcon(icon: String = definedExternally): Promise<Void>
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
fun setPosition(position: Position): Promise<Void>

Sets the window outer position.

Link copied to clipboard

Sets the taskbar progress state.

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

Updates the window resizable flag.

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

Whether or not the window should have shadow.

Link copied to clipboard

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: 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

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

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

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

Link copied to clipboard
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
fun show(): Promise<Void>

Sets the window visibility to true.

Link copied to clipboard

Starts dragging the window.

Link copied to clipboard

Starts resize-dragging the window.

Link copied to clipboard

Gets the window's current theme.

Link copied to clipboard

Gets the window's current title.

Link copied to clipboard

Toggles the window maximized state.

Link copied to clipboard

Unmaximizes the window.

Link copied to clipboard

Unminimizes the window.