• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cursor outside Rect without polling
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cursor outside Rect without polling


  • Subject: Re: Cursor outside Rect without polling
  • From: Quincey Morris <email@hidden>
  • Date: Mon, 19 Jun 2017 20:45:01 -0700

On Jun 19, 2017, at 20:17 , Gerriet M. Denkmann <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden

References: 
 >Cursor outside Rect without polling (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Cursor outside Rect without polling
  • Next by Date: Re: NSTimer or what?
  • Previous by thread: Cursor outside Rect without polling
  • Next by thread: UIDocumentBrowserViewController and file package documents
  • Index(es):
    • Date
    • Thread