Search code examples
cocoamacosnsmenunsmenuitem

First item in an NSMenu does not appear


I am making my own NSMenu programmatically and popping it up when a button is pressed.

I create NSMenuItems and add them with the NSMenu method insertItem:atIndex:.

For some reason whatever item is at position zero in the menu does not show up. Is this how the menu is supposed to work?


Solution

  • Yes, this is how the menu is supposed to work, if the NSPopUpButton pullsDown. The first item corresponds to the title of the button; just insert "" or whatever you want. It won't show up.