Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

macosus

macrumors newbie
Original poster
Aug 14, 2011
4
0
Like Google Chrome and some Xcode and Interface Builder controls, is there some way to make a button display a menu? I'm using this as an alternative to a Menubar.
 
You might try looking at the NSResponder method -menuForEvent: — this would almost certainly require subclassing NSButton, but customized behavior and effects are among the reasons that subclassing is there in the first place.
 
Perform the following steps in Xcode (Xcode 4) or Interface Builder (Xcode 3) to attach a menu to a button:

  1. Drag a pop-up button to the window.
  2. Open the pop-up button’s attributes inspector.
  3. Choose Pull Down from the Type pop-up menu
  4. Choose a button type from the Style pop-up menu.
  5. If you have an icon button, use the Image combo box to pick an image for the button.
  6. If you have an icon button, deselect the Bordered checkbox.
 
Be sure to think through your rationale for doing this. There are many cases where this is a great UX feature, but it is potentially much less discoverable for the user and can lead to confusion. In many cases, it would probably be a good idea to make this functionality also accessible in the menu bar. It really depends on your specific use case, but I mention this because it may merit significant UX consideration. See Apple's HIG for further reference.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.