Exact definition of NSView/NSEvent coordinate system origin?
Exact definition of NSView/NSEvent coordinate system origin?
- Subject: Exact definition of NSView/NSEvent coordinate system origin?
- From: "Sean McBride" <email@hidden>
- Date: Fri, 11 Aug 2017 12:38:28 -0400
- Organization: Rogue Research Inc.
Hi all,
I'm tying to understand the exact definition of the Cocoa drawing and event
coordinate system on macOS. In particular the exact location of 0,0 and
subpixel accuracy.
I know 0,0 is the bottom-left, but is it:
- the centre of the bottom-left pixel?
- the bottom-left corner of the bottom-left pixel?
I made a custom NSView and implemented mouseDown:
- (void)mouseDown:(NSEvent*)inEvent {
NSPoint viewPoint = [self convertPoint:[inEvent locationInWindow]
fromView:nil];
I then use Pixie.app at max magnification and click the bottom-left pixel,
yielding results like:
(lldb) p viewPoint
(NSPoint) $3 = (x = 0.15234375, y = 0.90625)
So it's giving fractional values, but they are hard to interpret without
knowing where 0,0 is exactly.
Then there's the 'locationInWindow' docs, that say "Note: The y coordinate in
the returned point starts from a base of 1, not 0." That's quite odd. Why?
Does anyone know the exact details here?
Thanks,
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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