Please give me an advice how to implement this kind of disclosure button as on my screenshot - a disclosure "arrow down" button displaying a menu on click:
I've tried two approaches, using NSPopupButton
and NSButton
with disclosure style and manual menu displaying:
NSPopupButton
keeps displaying default value text and can't be resized in Interface Builder to a narrow size.
NSButton
displays a menu, but it's obviously misplaced to the point where I click the button, not at the bottom edge. I'm using the following code:
- (IBAction)handleShowMenu:(id)sender
{
[NSMenu popUpContextMenu:profileMenu
withEvent:[NSApp currentEvent]
forView:sender];
}
So what's the right way to display such a menu?
I've managed with it! The correct setup is to use NSPopupButton
with "No Arrow" and "Disclosure" bezel style, "Momentary Push In" type.
Changing the bezel style of your popup button to "Textured" and the arrow to "Center" will give you the appearance of your first screenshot. If you don't want the title of the selected item to appear, you also need to set the "Position" to "image only" (the white square).
Edit: I tried this in IB 3 and only simulated the interface. It seems that the "Textured" style looks different in Xcode 4. "Round Textured" is close, but it doesn't center the triangle horizontally.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With