0

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.

Carter
  • 4,738
  • 2
  • 22
  • 24

2 Answers2

1

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).

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
  • This option had occurred to me and while I'm sure it works, it's really not the answer to my question. I shouldn't have to use an NSPopupButton when NSMenu's popUpMenuPositioningItem:atLocation:inView: should work. – Carter May 06 '12 at 13:42
1

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

rdelmar
  • 103,982
  • 12
  • 207
  • 218