wails icon indicating copy to clipboard operation
wails copied to clipboard

[v3] How to update the menu label in real time when the tray is open?

Open learning-go123 opened this issue 4 months ago • 4 comments

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)
	}

learning-go123 avatar Oct 05 '25 04:10 learning-go123

Update to latest alpha 35. https://github.com/wailsapp/wails/pull/4615

COD3HUNT3R avatar Oct 14 '25 03:10 COD3HUNT3R

Sorry, I tested it, but it doesn't work on Mac.

learning-go123 avatar Oct 15 '25 03:10 learning-go123

Do you have any examples of menus updating in realtime whilst they are open?

leaanthony avatar Nov 03 '25 08:11 leaanthony

@leaanthony the wifi menu on macos updates while it's open, for instance. Or the battery menu.

IanVS avatar Nov 19 '25 18:11 IanVS