mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
[V3] Update systray.mdx example (#4307)
* Update systray.mdx GUI operations must run on the main thread I guess? this example calling systray.Run() from a non-main thread context and it will panic. * Update systray.mdx OnClick function takes *application.Context. the example if not complete
This commit is contained in:
parent
3716acaae4
commit
83005be066
1 changed files with 4 additions and 4 deletions
|
|
@ -18,7 +18,7 @@ app := application.New(options)
|
|||
systray := app.NewSystemTray()
|
||||
systray.SetLabel("My App")
|
||||
systray.SetIcon(iconBytes)
|
||||
systray.Run()
|
||||
app.Run()
|
||||
```
|
||||
|
||||
## Setting the Icon
|
||||
|
|
@ -85,10 +85,10 @@ You can add a menu to your system tray icon:
|
|||
|
||||
```go
|
||||
menu := application.NewMenu()
|
||||
menu.Add("Open").OnClick(func() {
|
||||
menu.Add("Open").OnClick(func(ctx *application.Context) {
|
||||
// Handle click
|
||||
})
|
||||
menu.Add("Quit").OnClick(func() {
|
||||
menu.Add("Quit").OnClick(func(ctx *application.Context) {
|
||||
app.Quit()
|
||||
})
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ menu.Add("Quit").OnClick(func() {
|
|||
})
|
||||
systray.SetMenu(menu)
|
||||
|
||||
systray.Run()
|
||||
app.Run()
|
||||
```
|
||||
|
||||
## Icon Position <Badge text="macOS" variant="success" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue