Anyway to display a popup menu from a button?

Discussion in 'Mac Programming' started by macosus, Sep 25, 2011.

  1. macosus macrumors newbie

    Joined:
    Aug 14, 2011
    #1
    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.
     
  2. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #2
    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.
     
  3. szymczyk macrumors regular

    Joined:
    Mar 5, 2006
    #4
    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.
     
  4. GorillaPaws macrumors 6502a

    GorillaPaws

    Joined:
    Oct 26, 2003
    Location:
    Richmond, VA
    #5
    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.
     

Share This Page