[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:
Aram 2025-05-26 12:03:37 +01:00 committed by GitHub
commit 83005be066
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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" />