Pergunta

I have an NSButton that when clicked calls [NSMenu popUpMenuPositioningItem:atLocation:inView:]. The menu pops up in the proper location however the topmost NSMenuItem is always highlighted blue, as if the mouse was hovering over it, except that it's not. I can't seem to find any way to control the highlight of an NSMenuItem.

Looking at the screenshot you can see the menu is highlighted even though the mouse is still hovering over the NSButton.

enter image description here

How can I fix this? I don't want anything to be highlighted upon clicking the NSButton.

Foi útil?

Solução

If you pass nil for the first argument in popUpMenuPositioningItem:atLocation:inView:, then nothing is selected.

Outras dicas

Instead of popping up the menu yourself, replace your NSButton with an NSPopUpButton, set to the pull-down type, with the Bordered checkbox turned off (you may have to turn it on and then off again), possibly with the arrow style set to None (although I would leave it in).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top