1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

NSScreen giving me nonsensical coordinates

Discussion in 'Mac Programming' started by XnavxeMiyyep, Jan 18, 2009.

  1. macrumors 65816

    XnavxeMiyyep

    #1
    The coordinates assume that my screens are aligned at the bottom, which is not the case; they are aligned at the top, so screen 1 should be -1680, 0, 0, 1050.

    I suppose it wouldn't be a problem, except that my program interacts with AppleScript, which actually gets the proper coordinates. I can't just put a 150 pixel vertical offset (which is, of course, the difference in heights of the monitors), because I want to ultimately produce a real program. :(

    Am I missing something? Is there an alternative to NSScreen? I'm so close to finishing this project, but I can't make any sense out of this. :confused:
     

    Attached Files:

  2. Moderator emeritus

    kainjow

    #2
    0 in the y-axis in Cocoa/Quartz is the bottom of the screen, so it makes sense to me. What is the AppleScript doing?
     
  3. macrumors 6502a

    Sayer

    #3
    Quartz assumes the origin is in the lower left corner.

    Carbon will still assume the origin is in the top left corner, which explains the AppleScript result.

    So either work with what Quartz gives you or do some small amount of math on the results to massage them the way you think they should be.
     
  4. macrumors 65816

    XnavxeMiyyep

    #4
    Ok, thanks guys.:) That also explains why I thought the visible frame assumed the menubar was at the bottom.

    I'm working on a utility called Gridlock that allows you to move and resize windows based on coordinates on a hypothetical grid, and wanted to make it work on multiple screens.
     

Share This Page