Subject: Exact definition of NSView/NSEvent coordinate
system origin?

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]

I then use 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?


Sean McBride, B. Eng [email protected]
Rogue Research
Mac Software Developer Montréal, Québec, Canada


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)

Help/Unsubscribe/Update your Subscription:

This email sent to [email protected]

Programming list archiving by: Enterprise Git Hosting