Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 18, 2009, 08:21 PM   #1
XnavxeMiyyep
macrumors 65816
 
XnavxeMiyyep's Avatar
 
Join Date: Mar 2003
Location: Washington
Send a message via AIM to XnavxeMiyyep Send a message via MSN to XnavxeMiyyep Send a message via Yahoo to XnavxeMiyyep
NSScreen giving me nonsensical coordinates

Quote:
Originally Posted by controller.m
NSRect frameRect;

....

for(int i = 0; i < scns; i ++){

frameRect = [[[NSScreen screens] objectAtIndex:i] frame];
NSLog(@"Checking screen %i: %f %f %f %f",i,frameRect.origin.x,frameRect.origin.y,frameRect.origin.x+frameRect.size.width,frameRect.origin .y+frameRect.size.height);

...

}
Quote:
Originally Posted by Console
Checking screen 0: 0.000000 0.000000 1600.000000 1200.000000

...

Checking screen 1: -1680.000000 150.000000 0.000000 1200.000000
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.
Attached Images
 

Last edited by XnavxeMiyyep; Jan 18, 2009 at 09:00 PM. Reason: Accidentally wrote NSView in the title instead ofNSScreen
XnavxeMiyyep is offline   0 Reply With Quote
Old Jan 20, 2009, 02:07 PM   #2
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
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?
kainjow is offline   0 Reply With Quote
Old Jan 20, 2009, 02:17 PM   #3
Sayer
macrumors 6502a
 
Sayer's Avatar
 
Join Date: Jan 2002
Location: Austin, TX
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.
__________________
Obama is a true statesman whose experience as a state senator, half-term US Senator & guest lecturer in a Constitutional Law class has fully prepared him to take control of our nuclear arsenal.-Me
Sayer is offline   0 Reply With Quote
Old Jan 20, 2009, 03:52 PM   #4
XnavxeMiyyep
Thread Starter
macrumors 65816
 
XnavxeMiyyep's Avatar
 
Join Date: Mar 2003
Location: Washington
Send a message via AIM to XnavxeMiyyep Send a message via MSN to XnavxeMiyyep Send a message via Yahoo to XnavxeMiyyep
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.
XnavxeMiyyep is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Coordinate transformation between Popover and background view RonC iPhone/iPad Programming 2 Aug 11, 2011 04:44 PM
Give me iOS(on appletv) or give me death(of appletv) bonsaidetective Apple TV and Home Theater 9 Aug 30, 2010 05:42 PM
Give me Multi-Touch or Give me Death (or really bad carpal tunnel)! lookoverthere Apple, Industry and Internet Discussion 67 Aug 26, 2009 08:45 AM
Give me a game demo for mac to give the nvidea a run for its money harry20larry MacBook 8 Feb 28, 2009 02:15 AM
feels like the crowd is saying give me give me more! togermano Music Discussion 20 Jan 13, 2008 01:06 PM


All times are GMT -5. The time now is 11:01 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC