Michael Wildermuth
Michael Wildermuth

Reputation: 5852

Given a Global Screen Position in code, how do I figure on which monitor I am on?

I am given a global Screen position (x,y), and I have multiple monitors plugged into my Mac computer, how do I in Xcode (Objective-c) figure out which monitor am on.

Basically I need to know which index in the NSScreen list I am on, or how do I retrieve the global monitor space (coordinate system that includes all monitors)?

Upvotes: 0

Views: 263

Answers (1)

JWWalker
JWWalker

Reputation: 22717

Get the array of NSScreens, and iterate through it, testing NSPointInRect( myPt, [aScreen frame] ).

You don't say where you're getting your global (x, y). Some OS APIs assume a global coordinate space whose origin is at the top left of the main screen, while I think Cocoa puts the origin at the bottom left.

Upvotes: 1

Related Questions