5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 07:10:40 +08:00
wails/website/docs/reference/runtime/window.mdx
2021-09-27 19:35:30 +10:00

185 lines
3.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 index.html)
### 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.
### 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.
### 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.
### WindowSetRGBA
Go Signature: `WindowSetRGBA(ctx context.Context, col *options.RGBA)`
JS Signature: `WindowSetRGBA(col: RGBA)`
Sets the background colour of the window to the given [RGBA](window#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;
}
```
### RGBA
```ts
interface RGBA {
r,
g,
b,
a: number;
}
```