I'm trying to get NSPopUpButton
to render like a standard NSButton
with only an image set, but not having any luck.
Much like the "+" button in Mail.app:
I assume they did this with NSPopUpButton
. The obvious thing I've tried is:
NSMenuItem *imageItem = [[[NSMenuItem alloc] init] autorelease];
[imageItem setImage:[NSImage imageNamed:NSImageNameAddTemplate]];
[[popUpButton cell] setUsesItemFromMenu:NO];
[[popUpButton cell] setMenuItem:imageItem];
[[popUpButton cell] setImagePosition:NSImageOnly];
This doesn't show the image however, instead it just shows a pair of arrows (I suspect they're drawn over where the image would be). Calling [popUpButton setImage:...]
also does nothing.
Is there a documented way to do this, or does it come down to some custom subclassing?
To prevent the button from displaying the arrow:
[popupButton.cell setArrowPosition:NSPopUpNoArrow];