openGL GUIインターフェイスがあり、openGLディスプレイでこの特定のボタンが押されたときに呼び出されるポップアップメニューが必要です。NSPopUPButtonを押したときにポップアップするメニューと同様のメニューを表示したいのですが、Cocoaボタン自体を使用できません。これを実現する最良の方法は、NSPopupButtonCellを使用することのようです。Lispでコードを記述し、Objective-Cブリッジを介してCocoaにアクセスしているため、ここにコードを投稿できませんが、次の擬似コードがメニューを表示するように見えるかどうか、または明らかな欠陥があるかどうかを確認したかっただけです。私の論理:
• Pseudo Code for function that is called when button is pressed:
• Initialize an NSPopUpButtonCell Using initTextCell: "test" pullsDown: NO
• allocate an NSMenu using alloc
• add two menu items using addItem:
• set the menu of the popUpButtonCell to be the menu that was just allocated using setMenu:
• Next I tried two methods to try and get the menu to actually be displayed,
first I tried using drawWithFrame:inView: and when that did not work I also tried
using drawBezelWithFrame:inView: eventhough the docs said not to use but I just
tried it out of desperation.
• finally, when the draw methods did not work I tried using performClick: on the
popupButtonCell to try and simulate the click.
これらの方法はいずれも、メニューを表示するのに成功しませんでした。セルに含まれるメニューをプログラムでポップアップする他の方法はありますか?