views:

55

answers:

1

I have an NSPopUpButton inside a trackingArea. Now when I open the PopUp and select an item, the mouseExited: method gets called. Even if my mouse is still inside the trackingArea. I assume that that is because the NSMenu is a view itself and when I click the mouse it is not in the view with the tracking rect anymore.

How can i workaround this problem? Is there a way to set a tracking area on top of all views?

The tracking area I use:

NSUInteger options = NSTrackingMouseEnteredAndExited | NSTrackingActiveInKeyWindow;
NSTrackingArea* trackingArea = [[NSTrackingArea alloc] initWithRect:rect options:options owner:self userInfo:nil];
A: 

Try NSTrackingActiveInActiveApp instead of NSTrackingActiveInKeyWindow. I'm not sure about this offhand, but it's possible that the window resigns key status (but not main, which would be why its appearance doesn't change) when the menu begins tracking, so that the user can navigate the menu with the keyboard. (You could check this by being the window's delegate and responding to a couple of delegate messages.)

Of course, this does mean you'll have to check whether the window is main before handling the user's mouse movements.

Peter Hosey
The window is always key and main. It never resigns any of it when interacting with the menu. I start believing that this behavior is a bug in the framework...
V1ru8
Sounds like it. I'd file it: https://bugreport.apple.com/
Peter Hosey
Filed it, but they did not respond to it :-(
V1ru8
You only filed it not two weeks ago. It can take *months* for Apple to respond to a bug report, and the response is most often “duplicate of #…” (which is actually a good sign—they track how many people have filed each bug).
Peter Hosey
until now I always got a response after 3-4 working days and if not so I got never a answer. But maybe I just got lucky in these cases. So I should exercise more patience.
V1ru8