NSMenu 中的第一项不出现
我正在以编程方式制作自己的 NSMenu,并在按下按钮时弹出它。
我创建 NSMenuItems 并使用 NSMenu 方法 insertItem:atIndex:
添加它们。
由于某种原因,菜单中位于零位置的任何项目都不会显示。这是菜单应该如何工作的吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,如果 NSPopUpButton
pullsDown
,菜单应该是这样工作的。第一项对应按钮的标题;只需插入""
或您想要的任何内容。它不会显示出来。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.那么您正在以相反的顺序构建菜单(通过迭代调用
insertItem:anItem atIndex:0
)?为什么不直接从上到下构建它并连续调用addItem:
?我已经做过很多次了,从来没有遇到过物品消失的问题。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 calladdItem:
? I've done this lots and never had issues with items disappearing.