Re: Event Objects Return 1-Based Y Coordinate Values
Re: Event Objects Return 1-Based Y Coordinate Values
- Subject: Re: Event Objects Return 1-Based Y Coordinate Values
- From: Jens Alfke <email@hidden>
- Date: Mon, 27 Jun 2011 12:13:18 -0700
On Jun 27, 2011, at 11:39 AM, Richard Somers wrote:
> The documentation matches the behavior. Cocoa event objects do indeed return y coordinate values that are 1-based. A mouse click on the bottom left corner of a window or view yields the point (0, 1) in Cocoa and not (0, 0).
> ...
> The documentation is very clear on this behavior. The only thing that is left unsaid in the documentation is why this unusual behavior exists or what purpose it has.
It makes sense to me. Integer coordinates denote the grid lines between pixels, not the pixel centers. Likewise, the hot-spot of the cursor is in between pixels, not in the center of a pixel. In the case of the default arrow cursor, the hot-spot is at the tip of the arrow.
Put that together, and what you get is that if the tip pixel of the arrow cursor is positioned over the bottom pixel of the view, the hot-spot is actually at y=1.0.
This may seem a little unexpected, but I don’t think most programmers ever worry about it. Hit-testing shouldn’t require single-pixel accuracy anyway, so I doubt the user would notice if your calculations were a pixel off.
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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