I have an NSMenuItem that I need to update to show a progress (like Time machine does with it’s backup). The problem is that when I set a new title on that NSMenuItem and the title is not changing.
It is in fact changing when I close and reopen the menu, but I want to update it while the user is looking at it.
I also tried remove an item and re-inserting it with no result.
Any pointers?
This actually works with no additional effort if your updating code runs in the run loop mode which is used during menu tracking. This is
NSEventTrackingRunLoopMode, but you probably just want to useNSRunLoopCommonModesso the menu item title is correct when the menu is pulled down.Here’s a simple example of a menu item
foothat counts the number of seconds since the app launched: