• 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: NSView mouseDown truncated coordinates
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSView mouseDown truncated coordinates


  • Subject: Re: NSView mouseDown truncated coordinates
  • From: Ken Thomases <email@hidden>
  • Date: Sat, 26 Nov 2011 11:58:29 -0600

On Nov 25, 2011, at 7:17 PM, Steven Spencer wrote:

> I'm using a NSTrackingArea in a view to receive mouseMoved events.
> The cursor location in the mouseMoved and mouseDragged events have non-integer coordinates (as expected).
> e.g. x:140.601562 y:128.082031
>
> However, the mouseDown and mouseUp events always produce truncated coordinates.
> e.g. x:140.000000 y:128.000000

We've seen this, too.  It started happening with Lion.

I also don't think it's quite "as expected".  Among other things, the fractional part is generally constant for long periods, even while the integral part changes.  That is, you're not seeing high-precision movement, just non-integral coordinates.


> This causes inaccuracy with hit testing between mouseMoved and mouseDown.

> What is the correct way to obtain coordinates that are consistent across all the mouse events ?

As Jens suggested, you may wish to truncate the mouseMoved coordinates yourself.  Or, you may need to use floor().  You should check what happens for a display to the left and/or above the primary, which would have negative coordinates.

On the other hand, how is it causing inaccuracy?  How are you using the coordinates such that the difference is significant.  You generally shouldn't use '==' to compare floating point numbers in any case, for example.

Regards,
Ken

_______________________________________________

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: 
 >NSView mouseDown truncated coordinates (From: Steven Spencer <email@hidden>)

  • Prev by Date: Re: NSView mouseDown truncated coordinates
  • Next by Date: Re: "byte orders" question
  • Previous by thread: Re: NSView mouseDown truncated coordinates
  • Next by thread: Re: NSView mouseDown truncated coordinates
  • Index(es):
    • Date
    • Thread