Files

113 lines
2.5 KiB
Markdown
Raw Permalink Normal View History

2023-09-24 08:57:22 +10:00
# System Tray
2023-09-25 20:56:29 +10:00
The system tray houses notification area on a desktop environment, which can
contain both icons of currently-running applications and specific system
notifications.
2023-09-24 08:57:22 +10:00
2023-09-25 20:50:53 +10:00
You create a system tray by calling `app.NewSystemTray()`:
2023-09-24 08:57:22 +10:00
2023-09-25 20:50:53 +10:00
```go
// Create a new system tray
tray := app.NewSystemTray()
```
2023-09-24 08:57:22 +10:00
2023-09-25 20:50:53 +10:00
The following methods are available on the `SystemTray` type:
2023-09-24 08:57:22 +10:00
### SetLabel
API: `SetLabel(label string)`
2023-09-25 20:56:29 +10:00
The `SetLabel` method sets the tray's label.
2023-09-24 08:57:22 +10:00
### Label
API: `Label() string`
2023-09-25 20:56:29 +10:00
The `Label` method retrieves the tray's label.
2023-09-24 08:57:22 +10:00
### PositionWindow
API: `PositionWindow(*WebviewWindow, offset int) error`
2023-09-25 20:56:29 +10:00
The `PositionWindow` method calls both `AttachWindow` and `WindowOffset`
methods.
2023-09-24 08:57:22 +10:00
### SetIcon
API: `SetIcon(icon []byte) *SystemTray`
The `SetIcon` method sets the system tray's icon.
### SetDarkModeIcon
API: `SetDarkModeIcon(icon []byte) *SystemTray`
2023-09-25 20:56:29 +10:00
The `SetDarkModeIcon` method sets the system tray's icon when in dark mode.
2023-09-24 08:57:22 +10:00
### SetMenu
API: `SetMenu(menu *Menu) *SystemTray`
2023-09-25 20:56:29 +10:00
The `SetMenu` method sets the system tray's menu.
2023-09-24 08:57:22 +10:00
### Destroy
API: `Destroy()`
The `Destroy` method destroys the system tray instance.
### OnClick
API: `OnClick(handler func()) *SystemTray`
The `OnClick` method sets the function to execute when the tray icon is clicked.
### OnRightClick
API: `OnRightClick(handler func()) *SystemTray`
2023-09-25 20:56:29 +10:00
The `OnRightClick` method sets the function to execute when right-clicking the
tray icon.
2023-09-24 08:57:22 +10:00
### OnDoubleClick
API: `OnDoubleClick(handler func()) *SystemTray`
2023-09-25 20:56:29 +10:00
The `OnDoubleClick` method sets the function to execute when double-clicking the
tray icon.
2023-09-24 08:57:22 +10:00
### OnRightDoubleClick
API: `OnRightDoubleClick(handler func()) *SystemTray`
2023-09-25 20:56:29 +10:00
The `OnRightDoubleClick` method sets the function to execute when right
double-clicking the tray icon.
2023-09-24 08:57:22 +10:00
### AttachWindow
API: `AttachWindow(window *WebviewWindow) *SystemTray`
2023-09-25 20:56:29 +10:00
The `AttachWindow` method attaches a window to the system tray. The window will
be shown when the system tray icon is clicked.
2023-09-24 08:57:22 +10:00
### WindowOffset
API: `WindowOffset(offset int) *SystemTray`
2023-09-25 20:56:29 +10:00
The `WindowOffset` method sets the gap in pixels between the system tray and the
window.
2023-09-24 08:57:22 +10:00
### WindowDebounce
API: `WindowDebounce(debounce time.Duration) *SystemTray`
2023-09-25 20:56:29 +10:00
The `WindowDebounce` method sets a debounce time. In the context of Windows,
this is used to specify how long to wait before responding to a mouse up event
on the notification icon.
2023-09-24 08:57:22 +10:00
### OpenMenu
API: `OpenMenu()`
The `OpenMenu` method opens the menu associated with the system tray.