With the user interface resolution at a value other than 1.0, I noticed a small inconstancy in the converted y coordinate of a mouse event in my application. I had subtracted 1.0 from the y coordinate but something was still slightly off.

I did some testing and observed that the larger the user interface resolution scale factor got the more noticeable the inconstancy became. When I use the following code to convert a mouse event to view coordinates the inconstancy completely disappears.

NSPoint loc = [aView convertPointFromBase:[event locationInWindow]];
loc.y -= (1.0 / [[aView window] userSpaceScaleFactor]);

Apple's Cocoa Drawing Guide 2007-10-31 page 52 states " Cocoa event objects return y coordinate values that are 1-based instead of 0- based. Thus, a mouse click on the bottom left corner of a window or view would yield the point (0, 1) in Cocoa and not (0, 0). Only y- coordinates are 1-based."

So it would appear that the above statement is not exactly correct. The "1" value in the 1-based y coordinate apparently needs to be modified by the userSpaceScaleFactor.

Can anyone confirm this?

Regards,
Richard Somers

_______________________________________________

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

This email sent to [EMAIL PROTECTED]

Reply via email to