PopupMenu in Toolbar with macoslib?

Hi,
does anyone know if it is possible (using macoslib) to have an actual PopupMenu in a toolbar, (as opposed to a normal button which has a contextual type menu)?

I created a property called tiOPTIONS, then dragged a PopupMenu called PopupMenu1 above the actual window - and then tried to add it to the toolbar with this code:

[code]// CONSTRUCT A NEW TOOLBAR ITEM
t = New NSToolbar(“com.richard.toolbar”, addressOf ToolbarAction)

// SPECIFY THE DEFAULT ITEMS
t.DefaultItems = Array(NSToolbarSpaceItemIdentifier, “Options”, NSToolbarFlexibleSpaceItemIdentifier)

// SPECIFY THE ALLOWED ITEMS
t.AllowedItems = Array(“Options”)

// ADD THE OPTIONS BUTTON
tiOPTIONS = NSToolbarCustomItem(PopupMenu1)

// SHOW THE TOOLBAR
self.SetToolbar t[/code]

It then refuses to compile unless I change the following line of code to:

// ADD THE OPTIONS BUTTON tiOPTIONS = NSToolbarDropMenuItem(PopupMenu1)

When I do that - It compiles, but I get an illegal cast exception!

Thanks.

Here an old example that I had long forgotten.
but it is without macoslib

Thanks Axel - I will take a look at that :slight_smile: