Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining Screen Positions in Objective-C (NSScreen)

Using [NSScreen screens] I'm able to get all of the screens attached to the computer and their sizes, however I'm trying to find out their positions relative to each other (like in Arrangement in the Display preferences). Is there a way to do this? I've looked online and through the class references on Apple's developer site and found nothing. Thank you.

like image 416
Peter Zich Avatar asked Mar 13 '10 00:03

Peter Zich


1 Answers

For each of the screens returned by [NSScreen screens] you can call:

[screen frame]

to get an NSRect containing the size and offset of each screen. The "main" screen (i.e. the one with the menu bar) will have offset (0, 0).

This should be a lot simpler than handling the -deviceDescription.

like image 110
Alnitak Avatar answered Sep 28 '22 03:09

Alnitak