mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 02:30:48 +08:00

* docs: update changelog * feat: update website config * feat(website): add formatting configuration * docs: fix image resource paths and format documents * feat(website): update community guide page Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
246 lines
4.9 KiB
Plaintext
246 lines
4.9 KiB
Plaintext
---
|
|
sidebar_position: 4
|
|
---
|
|
|
|
# Window
|
|
|
|
## Overview
|
|
|
|
These methods give control of the application window.
|
|
|
|
### WindowSetTitle
|
|
|
|
Go Signature: `WindowSetTitle(ctx context.Context, title string)`
|
|
|
|
JS Signature: `WindowSetTitle(title: string)`
|
|
|
|
Sets the text in the window title bar.
|
|
|
|
### WindowFullscreen
|
|
|
|
Go Signature: `WindowFullscreen(ctx context.Context)`
|
|
|
|
JS Signature: `WindowFullscreen()`
|
|
|
|
Makes the window full screen.
|
|
|
|
### WindowUnfullscreen
|
|
|
|
Go Signature: `WindowUnfullscreen(ctx context.Context)`
|
|
|
|
JS Signature: `WindowUnfullscreen()`
|
|
|
|
Restores the previous window dimensions and position prior to full screen.
|
|
|
|
### WindowCenter
|
|
|
|
Go Signature: `WindowCenter(ctx context.Context)`
|
|
|
|
JS Signature: `WindowCenter()`
|
|
|
|
Centers the window on the monitor the window is currently on.
|
|
|
|
### WindowReload
|
|
|
|
Go Signature: `WindowReload(ctx context.Context)`
|
|
|
|
JS Signature: `WindowReload()`
|
|
|
|
Performs a "reload" (Reloads current page).
|
|
|
|
### WindowReloadApp
|
|
|
|
Go Signature: `WindowReloadApp(ctx context.Context)`
|
|
|
|
JS Signature: `WindowReloadApp()`
|
|
|
|
Reloads the application frontend.
|
|
|
|
### WindowSetSy
|
|
|
|
### WindowSetSystemDefaultTheme
|
|
|
|
Go Signature: `WindowSetSystemDefaultTheme(ctx context.Context)`
|
|
|
|
JS Signature: `WindowSetSystemDefaultTheme()`
|
|
|
|
Windows only.
|
|
|
|
Sets window theme to system default (dark/light).
|
|
|
|
### WindowSetLightTheme
|
|
|
|
Go Signature: `WindowSetLightTheme(ctx context.Context)`
|
|
|
|
JS Signature: `WindowSetLightTheme()`
|
|
|
|
Windows only.
|
|
|
|
Sets window theme to light.
|
|
|
|
### WindowSetDarkTheme
|
|
|
|
Go Signature: `WindowSetDarkTheme(ctx context.Context)`
|
|
|
|
JS Signature: `WindowSetDarkTheme()`
|
|
|
|
Windows only.
|
|
|
|
Sets window theme to dark.
|
|
|
|
### WindowShow
|
|
|
|
Go Signature: `WindowShow(ctx context.Context)`
|
|
|
|
JS Signature: `WindowShow()`
|
|
|
|
Shows the window, if it is currently hidden.
|
|
|
|
### WindowHide
|
|
|
|
Go Signature: `WindowHide(ctx context.Context)`
|
|
|
|
JS Signature: `WindowHide()`
|
|
|
|
Hides the window, if it is currently visible.
|
|
|
|
### WindowSetSize
|
|
|
|
Go Signature: `WindowSetSize(ctx context.Context, width int, height int)`
|
|
|
|
JS Signature: `WindowSetSize(size: Size)`
|
|
|
|
Sets the width and height of the window.
|
|
|
|
### WindowGetSize
|
|
|
|
Go Signature: `WindowGetSize(ctx context.Context) (width int, height int)`
|
|
|
|
JS Signature: `WindowGetSize() : Size`
|
|
|
|
Gets the width and height of the window.
|
|
|
|
### WindowSetMinSize
|
|
|
|
Go Signature: `WindowSetMinSize(ctx context.Context, width int, height int)`
|
|
|
|
JS Signature: `WindowSetMinSize(size: Size)`
|
|
|
|
Sets the minimum window size.
|
|
Will resize the window if the window is currently smaller than the given dimensions.
|
|
|
|
Setting a size of `0,0` will disable this constraint.
|
|
|
|
### WindowSetMaxSize
|
|
|
|
Go Signature: `WindowSetMaxSize(ctx context.Context, width int, height int)`
|
|
|
|
JS Signature: `WindowSetMaxSize(size: Size)`
|
|
|
|
Sets the maximum window size.
|
|
Will resize the window if the window is currently larger than the given dimensions.
|
|
|
|
Setting a size of `0,0` will disable this constraint.
|
|
|
|
### WindowSetAlwaysOnTop
|
|
|
|
Go Signature: `WindowSetAlwaysOnTop(ctx context.Context, b bool)`
|
|
|
|
JS Signature: `WindowSetAlwaysOnTop(b: Boolen)`
|
|
|
|
Sets the window AlwaysOnTop or not on top.
|
|
|
|
### WindowSetPosition
|
|
|
|
Go Signature: `WindowSetPosition(ctx context.Context, x int, y int)`
|
|
|
|
JS Signature: `WindowSetPosition(position: Position)`
|
|
|
|
Sets the window position relative to the monitor the window is currently on.
|
|
|
|
### WindowGetPosition
|
|
|
|
Go Signature: `WindowGetPosition(ctx context.Context) (x int, y int)`
|
|
|
|
JS Signature: `WindowGetPosition() : Position`
|
|
|
|
Gets the window position relative to the monitor the window is currently on.
|
|
|
|
### WindowMaximise
|
|
|
|
Go Signature: `WindowMaximise(ctx context.Context)`
|
|
|
|
JS Signature: `WindowMaximise()`
|
|
|
|
Maximises the window to fill the screen.
|
|
|
|
### WindowUnmaximise
|
|
|
|
Go Signature: `WindowUnmaximise(ctx context.Context)`
|
|
|
|
JS Signature: `WindowUnmaximise()`
|
|
|
|
Restores the window to the dimensions and position prior to maximising.
|
|
|
|
### WindowToggleMaximise
|
|
|
|
Go Signature: `WindowToggleMaximise(ctx context.Context)`
|
|
|
|
JS Signature: `WindowToggleMaximise()`
|
|
|
|
Toggles between Maximised and UnMaximised.
|
|
|
|
### WindowMinimise
|
|
|
|
Go Signature: `WindowMinimise(ctx context.Context)`
|
|
|
|
JS Signature: `WindowMinimise()`
|
|
|
|
Minimises the window.
|
|
|
|
### WindowUnminimise
|
|
|
|
Go Signature: `WindowUnminimise(ctx context.Context)`
|
|
|
|
JS Signature: `WindowUnminimise()`
|
|
|
|
Restores the window to the dimensions and position prior to minimising.
|
|
|
|
### WindowSetBackgroundColour
|
|
|
|
Go Signature: `WindowSetBackgroundColour(ctx context.Context, R, G, B, A uint8)`
|
|
|
|
JS Signature: `WindowSetBackgroundColour(R, G, B, A)`
|
|
|
|
Sets the background colour of the window to the given RGBA colour definition.
|
|
This colour will show through for all transparent pixels.
|
|
|
|
Valid values for R, G, B and A are 0-255.
|
|
|
|
:::info Windows
|
|
|
|
On Windows, only alpha values of 0 or 255 are supported.
|
|
Any value that is not 0 will be considered 255.
|
|
|
|
:::
|
|
|
|
## Typescript Object Definitions
|
|
|
|
### Position
|
|
|
|
```ts
|
|
interface Position {
|
|
x: number;
|
|
y: number;
|
|
}
|
|
```
|
|
|
|
### Size
|
|
|
|
```ts
|
|
interface Size {
|
|
w: number;
|
|
h: number;
|
|
}
|
|
```
|