Is it possible to put a PopupMenu in a macoslib created toolbar?
I have looked at the example, but there is no PopupMenu there; Plenty of other controls, but no PopupMenu
I even found this, which does a similar thing, but not via a PopupMenu:
dim td as new NSToolbarDropMenuItem("SelectToolbarItem")
Hope someone can help.
You add a Popupmenu to the NSToolbar just like any other control:
[code]//t is the NSToolbar
t.DefaultItems = array( _
//some more entries
t.AllowedItems = array( _
//some more entries
dim tc as NSToolbarCustomItem
tc = new NSToolbarCustomItem(PopupMenu1)
tc.itemLabel = “Select”
tc.paletteLabel = “Select”
tc.toolTip = “Select an option”
dim maxSize as Cocoa.NSSize // setup structures for max and min size in toolbar (optional but encouraged)
maxSize.height = 32
maxSize.width = 200
dim minSize as Cocoa.NSSize
minSize.height = 24
minSize.width = 100
tc.maxSize = maxSize
tc.minSize = minSize
Ahhh - I didn’t realise you could put any control in the toolbar. I thought only a certain few could be added.
So basically, any control I want in the toolbar just needs to be added to the window (off screen), and then added as in the example above?
Thank you so much Jason - it makes a lot more sense now
Two sub questions:
What does paletteLabel refer to, as that does not seem to be a native property of a PopupMenu?
In the ToolbarAction method, do I use the usual PopupMenu code - such as:
If identifier = "PopupMenu1" then
If PopupMenu1.Text = "Edit" Then
MsgBox("Edit was selected")
Bit lost as to how to determine the action for each item in the PopupMenu
[quote=112857:@Richard Summers]Two sub questions:
- What does paletteLabel refer to, as that does not seem to be a native property of a PopupMenu?
PaletteLabel is the label which appears under the toolbar item when you are customizing the toolbar (right click on the toolbar and select “Customize toolbar” and a sheet window appear with all of the available toolbar items) to give the user some insight into the purpose of the toolbar item.
[quote]2) In the ToolbarAction method, do I use the usual PopupMenu code - such as:
If identifier = “PopupMenu1” then
If PopupMenu1.Text = “Edit” Then
MsgBox(“Edit was selected”)
Bit lost as to how to determine the action for each item in the PopupMenu :([/quote]
You can use the change event of the popupmenu like you normally would (or any other event for that matter) and it will be fired when the user changes their selection in the popupmenu embedded in the toolbar.
Thanks Jason - I will look into what you just told me.