18 KiB
@tauri-apps/api / window / WindowManager
Class: WindowManager
window.WindowManager
Manage the current window object.
Hierarchy
-
↳
WindowManager
Constructors
constructor
• new WindowManager(label)
Parameters
| Name | Type |
|---|---|
label |
string |
Inherited from
WebviewWindowHandle.constructor
Defined in
Properties
label
• label: string
The window label. It is a unique identifier for the window, can be used to reference it later.
Inherited from
Defined in
listeners
• listeners: Object
Local event listeners.
Index signature
▪ [key: string]: EventCallback<any>[]
Inherited from
Defined in
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
center
▸ center(): Promise<void>
Centers the window.
Returns
Promise<void>
A promise indicating the success or failure of the operation.
Defined in
close
▸ close(): Promise<void>
Closes the window.
Returns
Promise<void>
A promise indicating the success or failure of the operation.
Defined in
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
Defined in
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
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
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
isDecorated
▸ isDecorated(): Promise<boolean>
Gets the window's current decorated state.
Returns
Promise<boolean>
Defined in
isFullscreen
▸ isFullscreen(): Promise<boolean>
Gets the window's current fullscreen state.
Returns
Promise<boolean>
Defined in
isMaximized
▸ isMaximized(): Promise<boolean>
Gets the window's current maximized state.
Returns
Promise<boolean>
Defined in
isResizable
▸ isResizable(): Promise<boolean>
Gets the window's current resizable state.
Returns
Promise<boolean>
Defined in
isVisible
▸ isVisible(): Promise<boolean>
Gets the window's current visible state.
Returns
Promise<boolean>
Defined in
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
Defined in
maximize
▸ maximize(): Promise<void>
Maximizes the window.
Returns
Promise<void>
A promise indicating the success or failure of the operation.
Defined in
minimize
▸ minimize(): Promise<void>
Minimizes the window.
Returns
Promise<void>
A promise indicating the success or failure of the operation.
Defined in
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
Defined in
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
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
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:
nullhas 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
scaleFactor
▸ scaleFactor(): Promise<number>
The scale factor that can be used to map physical pixels to logical pixels.
Returns
Promise<number>
Defined in
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
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
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
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
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
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
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
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
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
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
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
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
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
startDragging
▸ startDragging(): Promise<void>
Starts dragging the window.
Returns
Promise<void>
A promise indicating the success or failure of the operation.
Defined in
toggleMaximize
▸ toggleMaximize(): Promise<void>
Toggles the window maximized state.
Returns
Promise<void>
A promise indicating the success or failure of the operation.
Defined in
unmaximize
▸ unmaximize(): Promise<void>
Unmaximizes the window.
Returns
Promise<void>
A promise indicating the success or failure of the operation.
Defined in
unminimize
▸ unminimize(): Promise<void>
Unminimizes the window.
Returns
Promise<void>
A promise indicating the success or failure of the operation.