views:

298

answers:

1

I need to make a popup or pull down menu in Cocoa that will contain either an image or an image with text as the representation of the item. Can anyone suggest a way I could do this programatically?

+11  A: 

Any sort of menu in Cocoa, whether it's in the menubar, part of an NSPopUpButton, or a combobox, uses NSMenu to display its menu. The NSMenu displays a list of NSMenuItems. Each NSMenuItem has a -[NSMenuItem setImage:] method. Have you tried that?

Dave DeLong
Wow, I had actually just made a popup menu so this was quite trivial once I knew that I could just set the image like that, thanks!
Mike2012
As of 10.5, you can also use `-[NSMenuItem setView:]` to use any kind of NSView in a menu item. For example, sliders, steppers, etc. Don't get carried away with it, but notice how the Help menu in 10.5+ starts with a Spotlight-like search box...
Quinn Taylor