使用 Cocoa OSX 以编程方式实例化没有 NSPopUpButton 的 NSPopUPMenu

发布于 2024-08-14 18:14:31 字数 240 浏览 1 评论 0原文

不久前,我制作了一个可可小部件,它是一个按钮,按下该按钮时,会弹出一个弹出菜单并处理选择。使用 NSPopupMenuButton 类这非常简单,但现在我需要做一些稍微不同的事情。我有一个 openGL 小部件,当我单击该小部件的某个部分时,我需要弹出与从 NSPopupMenuButton 获得的相同弹出菜单,但没有按钮。我在 NSPopupMenuButton 的文档中找不到对此菜单类本身的任何引用。我想做的事情可能吗?或者我需要从头开始构建这个弹出菜单吗?

A while back I made a cocoa widget that was a button that when pressed, would pop up a popup menu and handle the selection. This was quite trivial using the NSPopupMenuButton class but now I need to do something slightly different. I have an openGL widget and when I click on a certain part of this widget, I need to pop up the same pop up menu that you get from the NSPopupMenuButton but without the button. I could not find any reference to this menu class itself inside the documentation for the NSPopupMenuButton. Is what I am trying to do possible? Or do I need to build this pop up menu from scratch?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吝吻 2024-08-21 18:14:31

没有单独的 NSPopUpMenu。 NSPopUpButton 的菜单是一个 NSMenu。

如果您想要一个没有弹出按钮的弹出菜单,则需要使用 NSPopUpButtonCell 来显示菜单。当然,这是假设您有充分的理由在 OpenGL 视图中伪造弹出按钮,而不是简单地使用标准 NSPopUpButton。

There is no separate NSPopUpMenu. The menu of an NSPopUpButton is an NSMenu.

If you want a pop-up menu without a pop-up button, you'll need to use NSPopUpButtonCell to display the menu. Of course, this is assuming you have a good reason to fake a pop-up button in an OpenGL view, instead of simply using the standard NSPopUpButton.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文