开发者

Programmatically instantiating a NSPopUPMenu without a NSPopUpButton with Cocoa OSX

开发者 https://www.devze.com 2022-12-13 22:20 出处:网络
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

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 possi开发者_高级运维ble? Or do I need to build this pop up menu from scratch?


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.

0

精彩评论

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