NSToolbarItem's with Dropdown Menus?

I've tried a few things to get dropdown menus working on my Catalyst toolbar.

Code Block
let barButton = UIBarButtonItem(systemItem: .add, primaryAction: UIAction(title: "Add", handler: { [weak self] _ in
... }), menu: menu)
let addItem = NSToolbarItem(itemIdentifier: .addItem, barButtonItem: barButton)


Even tried adding an itemMenuFormRepresentation, but no dice.

Code Block
addItem.itemMenuFormRepresentation = AppDelegate.newMenu


Has anyone got this working on Big Sur?
Answered by J0hn in 624828022
Found a french tweet that I ran through google translate and finally solved this insanity with NSMenuToolbar item. This is actually available in the previous version of catalyst and I had no idea.

Code Block
let addItem = NSMenuToolbarItem(itemIdentifier: .addItem)
addItem.itemMenu = menu
addItem.image = UIImage(systemName: "plus")

Accepted Answer
Found a french tweet that I ran through google translate and finally solved this insanity with NSMenuToolbar item. This is actually available in the previous version of catalyst and I had no idea.

Code Block
let addItem = NSMenuToolbarItem(itemIdentifier: .addItem)
addItem.itemMenu = menu
addItem.image = UIImage(systemName: "plus")

While your solution works for your problem, this isn't just a problem with menu:

It seems NSToolbarItem(itemIdentifier:, barButtonItem:) only works if you are using a #selector for your UIBarButtonItem. If you use primaryAction instead the button does nothing.
OMG thank you!
NSToolbarItem's with Dropdown Menus?
 
 
Q