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];
Try
NSTrackingActiveInActiveAppinstead ofNSTrackingActiveInKeyWindow. 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.