I am trying to interface with a cocoa popup menu from an OpenGL button. The actual button needs to be in OpenGL and I cannot stick an actual Cocoa button in its place but when this button is pressed I would like for a Cocoa menu to popup just like the one that comes up when you press the nspopupbutton. It seems that there is no way to get this popup window to come up by itself so I wanted to just insert an invisible button and have it be pressed automatically when the popup menu method is called. Is there a way to programmatically set a button to pressed (this will bring up the menu from the popupbutton) and make the button itself invisible without making the resulting menu invisible?
views:
249answers:
2
+1
A:
Have you thought about just using a regular NSMenu, rather than trying to finagle the menu from an NSPopupButton?
Ben Gottlieb
2009-12-16 18:31:31
Can you link to an example that shows how to popup a menu? An NSMenu is not a window right? So I would just need to associate the menu I bring up with the window I am currently working with? Thanks, I am quite a cocoa novice.
Mike2012
2009-12-16 18:39:18
As Darren answered, +popUpContextMenu:withEvent:forView: should do the trick.
Ben Gottlieb
2009-12-16 20:15:59
+2
A:
It seems that there is no way to get this popup window to come up by itself
Sure there is. See + popUpContextMenu:withEvent:forView:
Darren
2009-12-16 18:43:34