Files
archived-tauri-docs/docs/api/js/classes/window.WindowManager.md
2022-03-29 07:36:52 +02:00

18 KiB

@tauri-apps/api / window / WindowManager

Class: WindowManager

window.WindowManager

Manage the current window object.

Hierarchy

Constructors

constructor

new WindowManager(label)

Parameters

Name Type
label string

Inherited from

WebviewWindowHandle.constructor

Defined in

window.ts:254

Properties

label

label: string

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

Inherited from

WebviewWindowHandle.label

Defined in

window.ts:250


listeners

listeners: Object

Local event listeners.

Index signature

▪ [key: string]: EventCallback<any>[]

Inherited from

WebviewWindowHandle.listeners

Defined in

window.ts:252

Methods

_handleTauriEvent

_handleTauriEvent<T>(event, handler): boolean

Type parameters

Name
T

Parameters

Name Type
event string
handler EventCallback<T>

Returns

boolean

Inherited from

WebviewWindowHandle._handleTauriEvent

Defined in

window.ts:316


center

center(): Promise<void>

Centers the window.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:510


close

close(): Promise<void>

Closes the window.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:756


emit

emit(event, payload?): Promise<void>

Emits an event to the backend, tied to the webview window.

Parameters

Name Type Description
event string Event name. Must include only alphanumeric characters, -, /, : and _.
payload? unknown Event payload.

Returns

Promise<void>

Inherited from

WebviewWindowHandle.emit

Defined in

window.ts:305


hide

hide(): Promise<void>

Sets the window visibility to false.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:736


innerPosition

innerPosition(): Promise<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.

Returns

Promise<PhysicalPosition>

Defined in

window.ts:353


innerSize

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.

Returns

Promise<PhysicalSize>

Defined in

window.ts:388


isDecorated

isDecorated(): Promise<boolean>

Gets the window's current decorated state.

Returns

Promise<boolean>

Defined in

window.ts:455


isFullscreen

isFullscreen(): Promise<boolean>

Gets the window's current fullscreen state.

Returns

Promise<boolean>

Defined in

window.ts:423


isMaximized

isMaximized(): Promise<boolean>

Gets the window's current maximized state.

Returns

Promise<boolean>

Defined in

window.ts:439


isResizable

isResizable(): Promise<boolean>

Gets the window's current resizable state.

Returns

Promise<boolean>

Defined in

window.ts:471


isVisible

isVisible(): Promise<boolean>

Gets the window's current visible state.

Returns

Promise<boolean>

Defined in

window.ts:487


listen

listen<T>(event, handler): Promise<UnlistenFn>

Listen to an event emitted by the backend that is tied to the webview window.

Type parameters

Name
T

Parameters

Name Type Description
event EventName Event name. Must include only alphanumeric characters, -, /, : and _.
handler EventCallback<T> Event handler.

Returns

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event.

Inherited from

WebviewWindowHandle.listen

Defined in

window.ts:267


maximize

maximize(): Promise<void>

Maximizes the window.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:616


minimize

minimize(): Promise<void>

Minimizes the window.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:676


once

once<T>(event, handler): Promise<UnlistenFn>

Listen to an one-off event emitted by the backend that is tied to the webview window.

Type parameters

Name
T

Parameters

Name Type Description
event string Event name. Must include only alphanumeric characters, -, /, : and _.
handler EventCallback<T> Event handler.

Returns

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event.

Inherited from

WebviewWindowHandle.once

Defined in

window.ts:288


outerPosition

outerPosition(): Promise<PhysicalPosition>

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

Returns

Promise<PhysicalPosition>

Defined in

window.ts:369


outerSize

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.

Returns

Promise<PhysicalSize>

Defined in

window.ts:407


requestUserAttention

requestUserAttention(requestType): 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.

Providing null 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: null has no effect.
  • Linux: Urgency levels have the same effect.

Parameters

Name Type
requestType null | UserAttentionType

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:541


scaleFactor

scaleFactor(): Promise<number>

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

Returns

Promise<number>

Defined in

window.ts:337


setAlwaysOnTop

setAlwaysOnTop(alwaysOnTop): Promise<void>

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

Parameters

Name Type Description
alwaysOnTop boolean Whether the window should always be on top of other windows or not.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:799


setDecorations

setDecorations(decorations): Promise<void>

Whether the window should have borders and bars.

Parameters

Name Type Description
decorations boolean Whether the window should have borders and bars.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:777


setFocus

setFocus(): Promise<void>

Bring the window to front and focus.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:1007


setFullscreen

setFullscreen(fullscreen): Promise<void>

Sets the window fullscreen state.

Parameters

Name Type Description
fullscreen boolean Whether the window should go to fullscreen or not.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:986


setIcon

setIcon(icon): Promise<void>

Sets the window icon.

Note that you need the icon-ico or icon-png Cargo features to use this API. To enable it, change your Cargo.toml file:

[dependencies]
tauri = { version = "...", features = ["...", "icon-png"] }

Parameters

Name Type Description
icon string | Uint8Array Icon bytes or path to the icon file.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:1035


setMaxSize

setMaxSize(size): Promise<void>

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

example

import { appWindow, LogicalSize } from '@tauri-apps/api/window'
await appWindow.setMaxSize(new LogicalSize(600, 500))

Parameters

Name Type Description
size undefined | null | PhysicalSize | LogicalSize The logical or physical inner size, or null to unset the constraint.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:906


setMinSize

setMinSize(size): Promise<void>

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

example

import { appWindow, PhysicalSize } from '@tauri-apps/api/window'
await appWindow.setMinSize(new PhysicalSize(600, 500))

Parameters

Name Type Description
size undefined | null | PhysicalSize | LogicalSize The logical or physical inner size, or null to unset the constraint.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:864


setPosition

setPosition(position): Promise<void>

Sets the window outer position.

example

import { appWindow, LogicalPosition } from '@tauri-apps/api/window'
await appWindow.setPosition(new LogicalPosition(600, 500))

Parameters

Name Type Description
position PhysicalPosition | LogicalPosition The new position, in logical or physical pixels.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:948


setResizable

setResizable(resizable): Promise<void>

Updates the window resizable flag.

Parameters

Name Type
resizable boolean

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:573


setSize

setSize(size): Promise<void>

Resizes the window with a new inner size.

example

import { appWindow, LogicalSize } from '@tauri-apps/api/window'
await appWindow.setSize(new LogicalSize(600, 500))

Parameters

Name Type Description
size PhysicalSize | LogicalSize The logical or physical inner size.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:826


setSkipTaskbar

setSkipTaskbar(skip): Promise<void>

Whether to show the window icon in the task bar or not.

Parameters

Name Type Description
skip boolean true to hide window icon, false to show it.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:1060


setTitle

setTitle(title): Promise<void>

Sets the window title.

Parameters

Name Type Description
title string The new title

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:595


show

show(): Promise<void>

Sets the window visibility to true.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:716


startDragging

startDragging(): Promise<void>

Starts dragging the window.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:1081


toggleMaximize

toggleMaximize(): Promise<void>

Toggles the window maximized state.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:656


unmaximize

unmaximize(): Promise<void>

Unmaximizes the window.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:636


unminimize

unminimize(): Promise<void>

Unminimizes the window.

Returns

Promise<void>

A promise indicating the success or failure of the operation.

Defined in

window.ts:696