mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
New Systray example
This commit is contained in:
parent
79af667b7a
commit
dad7798da9
2 changed files with 33 additions and 0 deletions
BIN
exp/examples/systray/macos_template_icon.png
Normal file
BIN
exp/examples/systray/macos_template_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
33
exp/examples/systray/main.go
Normal file
33
exp/examples/systray/main.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"log"
|
||||
|
||||
"github.com/wailsapp/wails/exp/pkg/application"
|
||||
)
|
||||
|
||||
//go:embed macos_template_icon.png
|
||||
var macosIcon []byte
|
||||
|
||||
func main() {
|
||||
app := application.New()
|
||||
systemTray := app.NewSystemTray().SetIcon(macosIcon)
|
||||
|
||||
myMenu := app.NewMenu()
|
||||
myMenu.Add("Hello World!").OnClick(func(ctx *application.Context) {
|
||||
ctx.ClickedMenuItem().SetLabel("Clicked!")
|
||||
})
|
||||
myMenu.AddSeparator()
|
||||
myMenu.Add("Quit").OnClick(func(ctx *application.Context) {
|
||||
app.Quit()
|
||||
})
|
||||
|
||||
systemTray.SetMenu(myMenu)
|
||||
|
||||
err := app.Run()
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue