Files

262 lines
5.5 KiB
Plaintext
Raw Permalink Normal View History

2021-09-27 19:35:30 +10:00
---
sidebar_position: 4
---
# Window
These methods give control of the application window.
### WindowSetTitle
2021-09-27 19:35:30 +10:00
Sets the text in the window title bar.
2022-08-27 11:17:03 +10:00
Go: `WindowSetTitle(ctx context.Context, title string)`<br/>
JS: `WindowSetTitle(title: string)`
2021-09-27 19:35:30 +10:00
### WindowFullscreen
2021-09-27 19:35:30 +10:00
Makes the window full screen.
2022-08-27 11:17:03 +10:00
Go: `WindowFullscreen(ctx context.Context)`<br/>
JS: `WindowFullscreen()`
2022-02-19 20:29:55 +11:00
### WindowUnfullscreen
2021-09-27 19:35:30 +10:00
Restores the previous window dimensions and position prior to full screen.
2022-08-27 11:17:03 +10:00
Go: `WindowUnfullscreen(ctx context.Context)`<br/>
JS: `WindowUnfullscreen()`
2022-08-29 13:52:01 -07:00
### WindowIsFullscreen
Returns true if the window is full screen.
Go: `WindowIsFullscreen(ctx context.Context) bool`<br/>
2022-08-29 13:52:01 -07:00
JS: `WindowIsFullscreen() bool`
2021-09-27 19:35:30 +10:00
### WindowCenter
2021-09-27 19:35:30 +10:00
Centers the window on the monitor the window is currently on.
2022-08-27 11:17:03 +10:00
Go: `WindowCenter(ctx context.Context)`<br/>
JS: `WindowCenter()`
2022-10-05 08:44:23 +11:00
### WindowExecJS
Executes arbitrary JS code in the window.
This method runs the code in the browser asynchronously and returns immediately.
If the script causes any errors, they will only be available in the browser console.
Go: `WindowExecJS(ctx context.Context, js string)`
2021-09-27 19:35:30 +10:00
### WindowReload
Performs a "reload" (Reloads current page).
2022-08-27 11:17:03 +10:00
Go: `WindowReload(ctx context.Context)`<br/>
JS: `WindowReload()`
### WindowReloadApp
Reloads the application frontend.
2022-08-27 11:17:03 +10:00
Go: `WindowReloadApp(ctx context.Context)`<br/>
JS: `WindowReloadApp()`
2021-09-27 19:35:30 +10:00
### WindowSetSystemDefaultTheme
Windows only.
2022-08-27 11:17:03 +10:00
Go: `WindowSetSystemDefaultTheme(ctx context.Context)`<br/>
JS: `WindowSetSystemDefaultTheme()`
Sets window theme to system default (dark/light).
### WindowSetLightTheme
Windows only.
2022-08-27 11:17:03 +10:00
Go: `WindowSetLightTheme(ctx context.Context)`<br/>
JS: `WindowSetLightTheme()`
Sets window theme to light.
### WindowSetDarkTheme
Windows only.
2022-08-27 11:17:03 +10:00
Go: `WindowSetDarkTheme(ctx context.Context)`<br/>
JS: `WindowSetDarkTheme()`
Sets window theme to dark.
2021-09-27 19:35:30 +10:00
### WindowShow
2021-09-27 19:35:30 +10:00
Shows the window, if it is currently hidden.
2022-08-27 11:17:03 +10:00
Go: `WindowShow(ctx context.Context)`<br/>
JS: `WindowShow()`
2021-09-27 19:35:30 +10:00
### WindowHide
2021-09-27 19:35:30 +10:00
Hides the window, if it is currently visible.
2022-08-27 11:17:03 +10:00
Go: `WindowHide(ctx context.Context)`<br/>
JS: `WindowHide()`
2022-08-29 13:52:01 -07:00
### WindowIsNormal
Returns true if the window not minimised, maximised or fullscreen.
Go: `WindowIsNormal(ctx context.Context) bool`<br/>
2022-08-29 13:52:01 -07:00
JS: `WindowIsNormal() bool`
2021-09-27 19:35:30 +10:00
### WindowSetSize
2021-09-27 19:35:30 +10:00
Sets the width and height of the window.
2022-08-27 11:17:03 +10:00
Go: `WindowSetSize(ctx context.Context, width int, height int)`<br/>
2023-08-29 06:12:10 +08:00
JS: `WindowSetSize(width: number, height: number)`
2022-08-27 11:17:03 +10:00
2021-09-27 19:35:30 +10:00
### WindowGetSize
2021-09-27 19:35:30 +10:00
Gets the width and height of the window.
2022-08-27 11:17:03 +10:00
Go: `WindowGetSize(ctx context.Context) (width int, height int)`<br/>
JS: `WindowGetSize() : Size`
2021-09-27 19:35:30 +10:00
### WindowSetMinSize
2021-09-27 19:35:30 +10:00
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.
2022-08-27 11:17:03 +10:00
Go: `WindowSetMinSize(ctx context.Context, width int, height int)`<br/>
2023-08-29 06:12:10 +08:00
JS: `WindowSetMinSize(width: number, height: number)`
2022-08-27 11:17:03 +10:00
2021-09-27 19:35:30 +10:00
### WindowSetMaxSize
2021-09-27 19:35:30 +10:00
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.
2022-08-27 11:17:03 +10:00
Go: `WindowSetMaxSize(ctx context.Context, width int, height int)`<br/>
2023-08-29 06:12:10 +08:00
JS: `WindowSetMaxSize(width: number, height: number)`
2022-08-27 11:17:03 +10:00
### WindowSetAlwaysOnTop
Sets the window AlwaysOnTop or not on top.
2022-08-27 11:17:03 +10:00
Go: `WindowSetAlwaysOnTop(ctx context.Context, b bool)`<br/>
JS: `WindowSetAlwaysOnTop(b: Boolen)`
2021-09-27 19:35:30 +10:00
### WindowSetPosition
2021-09-27 19:35:30 +10:00
Sets the window position relative to the monitor the window is currently on.
2022-08-27 11:17:03 +10:00
Go: `WindowSetPosition(ctx context.Context, x int, y int)`<br/>
2023-08-29 06:12:10 +08:00
JS: `WindowSetPosition(x: number, y: number)`
2022-08-27 11:17:03 +10:00
2021-09-27 19:35:30 +10:00
### WindowGetPosition
2021-09-27 19:35:30 +10:00
Gets the window position relative to the monitor the window is currently on.
2022-08-27 11:17:03 +10:00
Go: `WindowGetPosition(ctx context.Context) (x int, y int)`<br/>
JS: `WindowGetPosition() : Position`
2021-09-27 19:35:30 +10:00
### WindowMaximise
2021-09-27 19:35:30 +10:00
Maximises the window to fill the screen.
2022-08-27 11:17:03 +10:00
Go: `WindowMaximise(ctx context.Context)`<br/>
JS: `WindowMaximise()`
2021-09-27 19:35:30 +10:00
### WindowUnmaximise
2021-09-27 19:35:30 +10:00
Restores the window to the dimensions and position prior to maximising.
2022-08-27 11:17:03 +10:00
Go: `WindowUnmaximise(ctx context.Context)`<br/>
JS: `WindowUnmaximise()`
2022-08-29 13:52:01 -07:00
### WindowIsMaximised
Returns true if the window is maximised.
Go: `WindowIsMaximised(ctx context.Context) bool`<br/>
2022-08-29 13:52:01 -07:00
JS: `WindowIsMaximised() bool`
2022-02-18 20:28:16 +11:00
### WindowToggleMaximise
2022-02-18 20:28:16 +11:00
Toggles between Maximised and UnMaximised.
2022-08-27 11:17:03 +10:00
Go: `WindowToggleMaximise(ctx context.Context)`<br/>
JS: `WindowToggleMaximise()`
2021-09-27 19:35:30 +10:00
### WindowMinimise
2021-09-27 19:35:30 +10:00
Minimises the window.
2022-08-27 11:17:03 +10:00
Go: `WindowMinimise(ctx context.Context)`<br/>
JS: `WindowMinimise()`
2021-09-27 19:35:30 +10:00
### WindowUnminimise
2021-09-27 19:35:30 +10:00
Restores the window to the dimensions and position prior to minimising.
2022-08-27 11:17:03 +10:00
Go: `WindowUnminimise(ctx context.Context)`<br/>
JS: `WindowUnminimise()`
2022-08-29 13:52:01 -07:00
### WindowIsMinimised
Returns true if the window is minimised.
Go: `WindowIsMinimised(ctx context.Context) bool`<br/>
2022-08-29 13:52:01 -07:00
JS: `WindowIsMinimised() bool`
### WindowSetBackgroundColour
2022-02-19 20:29:55 +11:00
Sets the background colour of the window to the given RGBA colour definition.
2021-09-27 19:35:30 +10:00
This colour will show through for all transparent pixels.
Valid values for R, G, B and A are 0-255.
:::info Windows
2021-09-27 19:35:30 +10:00
On Windows, only alpha values of 0 or 255 are supported.
Any value that is not 0 will be considered 255.
2021-09-27 19:35:30 +10:00
:::
2022-08-27 11:17:03 +10:00
Go: `WindowSetBackgroundColour(ctx context.Context, R, G, B, A uint8)`<br/>
JS: `WindowSetBackgroundColour(R, G, B, A)`
2023-09-16 14:58:24 +10:00
### WindowPrint
Opens tha native print dialog.
Go: `WindowPrint(ctx context.Context)`<br/>
JS: `WindowPrint()`
2022-11-28 17:13:22 +08:00
## TypeScript Object Definitions
2021-09-27 19:35:30 +10:00
### Position
```ts
interface Position {
x: number;
y: number;
2021-09-27 19:35:30 +10:00
}
```
### Size
```ts
interface Size {
w: number;
h: number;
2021-09-27 19:35:30 +10:00
}
```