Search code examples
cocoansmenunsmenuitemnsstatusitem

How force NSMenuItem to redraw?


I'm implementing a custom status bar menu, which has a custom view with NSSearchField. I'm updating number of menu items according to search results. The number of menu items is changed as user types in the NSSearchField. I've noticed, that if number of results stays the same, items titles are not updated (redrawn). How do I force them to redraw?

In the function, that rebuilds the menu I remove first all items and then create new items according to the search results.

Thanks,

Nava


Solution

  • I could achieve it by following approach: When the number of search results is the same, i don't recreate them, just change the title and call itemChanged:. When the count is different I recreate menu items. This works anyway. But I was advised anyway to get back from using menu for this purposes.