I am trying to make a popup button that always displays a + as its image and when you click on it, a context menu pops up that will allow you to decide what type of object you want to add. Is there anyway to do this using an NSPopupButton? I saw in the specs for NSPopupButotn that the method SetImage has no effect so it seems that this is likely not going to work using this class. Is this correct?
Yes, the visible appearance of NSPopUpButton
is wrong for what you want.
What you want is a regular NSButton
with a menu attached. In Interface Builder clear the title, set the Bezel to Square, the Position to the center icon-only version and the image to NSAddTemplate
.
Then create a NSPopUpButton
, set it to "Pull Down", hidden, and align it/set its size to the bottom of the NSButton.
Finally, connect performClick:
in the NSButton
to performClick:
on the NSPopUpButton
.
That won't handle a click-hold on the button; for that you'll have to write some code to use a (non-drawing) NSPopUpButtonCell
.