J'ai une interface GUI openGL et j'ai besoin d'un menu contextuel qui sera appelé quand un certain bouton est pressé dans mon affichage openGL. Je veux afficher un menu similaire à celui qui apparaît lorsque vous appuyez sur un NSPopUPButton mais je ne peux pas utiliser le bouton Cocoa lui-même. Il semble que la meilleure façon d'accomplir ceci est d'utiliser NSPopupButtonCell. Je ne peux pas poster mon code ici parce que j'écris le code en Lisp et j'accède au Cocoa via un pont C objectif mais je voulais juste voir si le code pseduo suivant devrait afficher le menu ou s'il y a un défaut évident dans mon logique:Instancier par programme un NSPopUpButtonCell dans Cocoa OSX
• 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.
Aucune de ces méthodes n'a réussi à afficher un type quelconque de menu. Existe-t-il un autre moyen de faire apparaître par programme le menu contenu dans la cellule?
Cela a fait l'affaire merci. – Mike2012