On Jun 19, 2017, at 20:17 , Gerriet M. Denkmann <gerri...@icloud.com> wrote: > > 1. if the cursor is initially NOT in the rect, the app does not get notified: > Workaround: user moves cursor into the rect (not very good). > > 2. if the app is hidden under some other windows, it also does not get > notified. > Workaround: user removes covering windows of other apps, then moves cursor > into the rect (even worse).
Here’s what I use: [[NSTrackingArea alloc] initWithRect: NSZeroRect options: (NSTrackingInVisibleRect | NSTrackingCursorUpdate | // maybe you don’t need this NSTrackingMouseMoved | NSTrackingActiveInKeyWindow | // maybe you need NSTrackingActiveAlways NSTrackingMouseEnteredAndExited | NSTrackingEnabledDuringMouseDrag | NSTrackingAssumeInside) owner: self userInfo: nil]; 1. Note that the documentation for NSTrackingAssumeInside is very misleading, and you should generally include this flag. (I just looked at the latest documentation, and the description has been rewritten *again*, and it looks plain wrong, since it seems to describe the same behavior when the flag is on as when it is off.) I just recall that NSTrackingAssumeInside causes tracking to fail less often. (There’s a defect in the mechanism that means it’s not 100% reliable initially. You may still need an explicit test to find out where the cursor is at the time you add the tracking area.) 2. If you need to keep tracking the inside/outside status, then maybe you need NSTrackingActiveAlways, to know where it is always, even if you don’t update the UI (or whatever) until your app becomes active again. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com