On Thu, Jan 26, 2012 at 11:41 AM, koko <k...@highrolls.net> wrote:
> The docs say that - (NSPoint)convertBaseToScreen:(NSPoint)point is deprecated 
> and to use - (NSRect)convertRectToScreen:(NSRect)aRect
>
> So, does one create a rect whose origin is the point in question and whose 
> size is zero?

Just like any other rect: use NSMakeRect(), or just set the fields directly.

But more importantly, read the section of the AppKit release notes
named "Changes for Resolution Independence":
http://developer.apple.com/library/mac/#releasenotes/Cocoa/AppKit.html

In Mac OS X 10.7, the "base" coordinate system doesn't exist anymore;
windows and screens share the same coordinate system, modulo the
origin. All -[NSWindow convertRectToScreen:] does is translate the
passed-in rect by the window's origin. No scaling is required.

So you could just as easily translate a point yourself:

NSWindow window = /* ...*/
NSPoint pointInWindowSpace = /* ... */;
NSPoint pointInScreenSpace;

NSPoint windowOrigin = [window frame].origin;
pointInScreenSpace.x = pointInWindowSpace.x - (windowOrigin.x);
pointInScreenSpace.y = pointInWindowSpace.y - (windowOrigin.y);

Nonetheless, you should file a radar asking for -[NSWindow
convertPoint{To,From}Screen:]. This is precisely the kind of tedious
code that I find myself screwing up on a regular basis. Heck, I
might've even screwed it up in this email.

>    NSRect cr = [keyWindow convertRectToScreen:r];
>
> The last line throws one error and a warning:
>
> No viable conversion from 'id' to 'NSRect' (aka '_NSrect')
> instance method '-convertRectToScreen' not found (return type defaults to 
> 'id')
>
> But -convertRectToScreen ins in the NSWindow reference.
>
> So what am I missing?

Are you not building with the 10.7 SDK? Or is your Maximum Deployment
Version set to 10.6 or earlier?

--Kyle Sluder

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to