wails
wails copied to clipboard
[v3] How to update the menu label in real time when the tray is open?
Calling menu.Update() doesn't re-render the UI in real time. It only changes when I reopen the System Tray menu. I'm not sure if this is due to my incorrect usage.
app := application.New(application.Options{
Name: "Systray Demo",
Description: "A demo of the Systray API",
})
systemTray := app.SystemTray.New()
if runtime.GOOS == "darwin" {
systemTray.SetTemplateIcon(icons.SystrayMacTemplate)
}
myMenu := app.NewMenu()
loading := myMenu.Add("loading...")
systemTray.SetMenu(myMenu)
go func() {
for i := 0; i <= 100; i++ {
time.Sleep(1 * time.Second)
loading.SetLabel("Loading " + strconv.Itoa(i))
myMenu.Update()
}
}()
err := app.Run()
if err != nil {
log.Fatal(err)
}
Update to latest alpha 35. https://github.com/wailsapp/wails/pull/4615
Sorry, I tested it, but it doesn't work on Mac.
Do you have any examples of menus updating in realtime whilst they are open?
@leaanthony the wifi menu on macos updates while it's open, for instance. Or the battery menu.