开发者

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?


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.


So you're building your menu in reverse order (by iteratively calling insertItem:anItem atIndex:0)? Why not just build it from the top down and successively call addItem:? I've done this lots and never had issues with items disappearing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜