macOS 11 Big Sur in its current iteration (beta 1 through beta 6) has a bug/feature that makes it hard to have NSMenuItem with the custom view. Specifically, the custom view of an item won't get a draw(dirtyRect:) call when the menu item gets highlighted.
I managed to bypass that bug by manually calling the draw(dirtyRect:) method via the NSMenu delegate:
func menu(_ menu: NSMenu, willHighlight item: NSMenuItem?) {
if #available(OSX 11.0, *) {
// fix for bug when an item with custom view won't be called to draw the highlighting state
menu.items.filter{ $0.tag == 101 }.forEach{ $0.view?.needsDisplay = true }
}
}
But that doesn't solve the mystery of the drawing the state. MacOS 11 Big Sur has new UI look. And menu items now highlight in a different way, with rounded box around its content.
My question is: should I simulate that rounded box manually, or there's some default way in new App Kit to draw that rounded selection of menu items?
In other words, what is the best way to have NSmenuItem with custom view in macOS 11 Big Sur?