mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 22:49:31 +08:00

* Add Check for WindowState IsMaximised, IsMinimized, IsNormal and IsFullscreen Solve conflicts # Conflicts: # v2/internal/frontend/desktop/darwin/WailsContext.m # v2/internal/frontend/desktop/darwin/frontend.go # v2/internal/frontend/desktop/linux/window.go # v2/internal/frontend/desktop/windows/window.go * Add Check for WindowState IsMaximised, IsMinimized, IsNormal and IsFullscreen Solve conflict # Conflicts: # v2/pkg/runtime/window.go * Forgot some function to use it # Conflicts: # v2/internal/frontend/desktop/darwin/WailsContext.h # v2/internal/frontend/desktop/windows/win32/consts.go # v2/internal/frontend/desktop/windows/win32/window.go * Modify the instructions # Conflicts: # v2/internal/frontend/devserver/devserver.go * Add Functions to DevServer # Conflicts: # v2/internal/frontend/dispatcher/systemcalls.go # v2/internal/frontend/runtime/desktop/window.js # v2/internal/frontend/runtime/package-lock.json # v2/internal/frontend/runtime/runtime_prod_desktop.js # v2/internal/frontend/runtime/wrapper/runtime.d.ts # v2/internal/frontend/runtime/wrapper/runtime.js * Add Callback and JavaScript Functions # Conflicts: # v2/cmd/wails/internal/commands/initialise/templates/generate/assets/common/frontend/wailsjs/runtime/runtime.js # v2/internal/frontend/runtime/package-lock.json # v2/internal/frontend/runtime/runtime_dev_desktop.js * Remove Merge lines * Fix IsMaximised * Add WindowState Docs * Update docs Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
244 lines
5.1 KiB
Plaintext
244 lines
5.1 KiB
Plaintext
---
|
|
sidebar_position: 4
|
|
---
|
|
|
|
# Window
|
|
|
|
These methods give control of the application window.
|
|
|
|
### WindowSetTitle
|
|
|
|
Sets the text in the window title bar.
|
|
|
|
Go: `WindowSetTitle(ctx context.Context, title string)`<br/>
|
|
JS: `WindowSetTitle(title: string)`
|
|
|
|
### WindowFullscreen
|
|
|
|
Makes the window full screen.
|
|
|
|
Go: `WindowFullscreen(ctx context.Context)`<br/>
|
|
JS: `WindowFullscreen()`
|
|
|
|
### WindowUnfullscreen
|
|
|
|
Restores the previous window dimensions and position prior to full screen.
|
|
|
|
Go: `WindowUnfullscreen(ctx context.Context)`<br/>
|
|
JS: `WindowUnfullscreen()`
|
|
|
|
### WindowIsFullscreen
|
|
|
|
Returns true if the window is full screen.
|
|
|
|
Go: `WindowIsFullscreen(ctx context.Context) bool`
|
|
JS: `WindowIsFullscreen() bool`
|
|
|
|
### WindowCenter
|
|
|
|
Centers the window on the monitor the window is currently on.
|
|
|
|
Go: `WindowCenter(ctx context.Context)`<br/>
|
|
JS: `WindowCenter()`
|
|
|
|
### WindowReload
|
|
|
|
Performs a "reload" (Reloads current page).
|
|
|
|
Go: `WindowReload(ctx context.Context)`<br/>
|
|
JS: `WindowReload()`
|
|
|
|
### WindowReloadApp
|
|
|
|
Reloads the application frontend.
|
|
|
|
Go: `WindowReloadApp(ctx context.Context)`<br/>
|
|
JS: `WindowReloadApp()`
|
|
|
|
### WindowSetSystemDefaultTheme
|
|
|
|
Windows only.
|
|
|
|
Go: `WindowSetSystemDefaultTheme(ctx context.Context)`<br/>
|
|
JS: `WindowSetSystemDefaultTheme()`
|
|
|
|
Sets window theme to system default (dark/light).
|
|
|
|
### WindowSetLightTheme
|
|
|
|
Windows only.
|
|
|
|
Go: `WindowSetLightTheme(ctx context.Context)`<br/>
|
|
JS: `WindowSetLightTheme()`
|
|
|
|
Sets window theme to light.
|
|
|
|
### WindowSetDarkTheme
|
|
|
|
Windows only.
|
|
|
|
Go: `WindowSetDarkTheme(ctx context.Context)`<br/>
|
|
JS: `WindowSetDarkTheme()`
|
|
|
|
Sets window theme to dark.
|
|
|
|
### WindowShow
|
|
|
|
Shows the window, if it is currently hidden.
|
|
|
|
Go: `WindowShow(ctx context.Context)`<br/>
|
|
JS: `WindowShow()`
|
|
|
|
### WindowHide
|
|
|
|
Hides the window, if it is currently visible.
|
|
|
|
Go: `WindowHide(ctx context.Context)`<br/>
|
|
JS: `WindowHide()`
|
|
|
|
### WindowIsNormal
|
|
|
|
Returns true if the window not minimised, maximised or fullscreen.
|
|
|
|
Go: `WindowIsNormal(ctx context.Context) bool`
|
|
JS: `WindowIsNormal() bool`
|
|
|
|
### WindowSetSize
|
|
|
|
Sets the width and height of the window.
|
|
|
|
Go: `WindowSetSize(ctx context.Context, width int, height int)`<br/>
|
|
JS: `WindowSetSize(size: Size)`
|
|
|
|
### WindowGetSize
|
|
|
|
Gets the width and height of the window.
|
|
|
|
Go: `WindowGetSize(ctx context.Context) (width int, height int)`<br/>
|
|
JS: `WindowGetSize() : Size`
|
|
|
|
### WindowSetMinSize
|
|
|
|
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.
|
|
|
|
Go: `WindowSetMinSize(ctx context.Context, width int, height int)`<br/>
|
|
JS: `WindowSetMinSize(size: Size)`
|
|
|
|
### WindowSetMaxSize
|
|
|
|
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.
|
|
|
|
Go: `WindowSetMaxSize(ctx context.Context, width int, height int)`<br/>
|
|
JS: `WindowSetMaxSize(size: Size)`
|
|
|
|
### WindowSetAlwaysOnTop
|
|
|
|
Sets the window AlwaysOnTop or not on top.
|
|
|
|
Go: `WindowSetAlwaysOnTop(ctx context.Context, b bool)`<br/>
|
|
JS: `WindowSetAlwaysOnTop(b: Boolen)`
|
|
|
|
### WindowSetPosition
|
|
|
|
Sets the window position relative to the monitor the window is currently on.
|
|
|
|
Go: `WindowSetPosition(ctx context.Context, x int, y int)`<br/>
|
|
JS: `WindowSetPosition(position: Position)`
|
|
|
|
### WindowGetPosition
|
|
|
|
Gets the window position relative to the monitor the window is currently on.
|
|
|
|
Go: `WindowGetPosition(ctx context.Context) (x int, y int)`<br/>
|
|
JS: `WindowGetPosition() : Position`
|
|
|
|
### WindowMaximise
|
|
|
|
Maximises the window to fill the screen.
|
|
|
|
Go: `WindowMaximise(ctx context.Context)`<br/>
|
|
JS: `WindowMaximise()`
|
|
|
|
### WindowUnmaximise
|
|
|
|
Restores the window to the dimensions and position prior to maximising.
|
|
|
|
Go: `WindowUnmaximise(ctx context.Context)`<br/>
|
|
JS: `WindowUnmaximise()`
|
|
|
|
### WindowIsMaximised
|
|
|
|
Returns true if the window is maximised.
|
|
|
|
Go: `WindowIsMaximised(ctx context.Context) bool`
|
|
JS: `WindowIsMaximised() bool`
|
|
|
|
### WindowToggleMaximise
|
|
|
|
Toggles between Maximised and UnMaximised.
|
|
|
|
Go: `WindowToggleMaximise(ctx context.Context)`<br/>
|
|
JS: `WindowToggleMaximise()`
|
|
|
|
### WindowMinimise
|
|
|
|
Minimises the window.
|
|
|
|
Go: `WindowMinimise(ctx context.Context)`<br/>
|
|
JS: `WindowMinimise()`
|
|
|
|
### WindowUnminimise
|
|
|
|
Restores the window to the dimensions and position prior to minimising.
|
|
|
|
Go: `WindowUnminimise(ctx context.Context)`<br/>
|
|
JS: `WindowUnminimise()`
|
|
|
|
### WindowIsMinimised
|
|
|
|
Returns true if the window is minimised.
|
|
|
|
Go: `WindowIsMinimised(ctx context.Context) bool`
|
|
JS: `WindowIsMinimised() bool`
|
|
|
|
### WindowSetBackgroundColour
|
|
|
|
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.
|
|
:::
|
|
|
|
Go: `WindowSetBackgroundColour(ctx context.Context, R, G, B, A uint8)`<br/>
|
|
JS: `WindowSetBackgroundColour(R, G, B, A)`
|
|
|
|
## Typescript Object Definitions
|
|
|
|
### Position
|
|
|
|
```ts
|
|
interface Position {
|
|
x: number;
|
|
y: number;
|
|
}
|
|
```
|
|
|
|
### Size
|
|
|
|
```ts
|
|
interface Size {
|
|
w: number;
|
|
h: number;
|
|
}
|
|
```
|