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 protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to