• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: - (NSPoint)convertBaseToScreen:(NSPoint)point
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: - (NSPoint)convertBaseToScreen:(NSPoint)point


  • Subject: Re: - (NSPoint)convertBaseToScreen:(NSPoint)point
  • From: Kyle Sluder <email@hidden>
  • Date: Thu, 26 Jan 2012 13:18:04 -0800

On Thu, Jan 26, 2012 at 11:41 AM, koko <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden


References: 
 >- (NSPoint)convertBaseToScreen:(NSPoint)point (From: koko <email@hidden>)

  • Prev by Date: - (NSPoint)convertBaseToScreen:(NSPoint)point
  • Next by Date: ARC and blocks
  • Previous by thread: - (NSPoint)convertBaseToScreen:(NSPoint)point
  • Next by thread: Re: - (NSPoint)convertBaseToScreen:(NSPoint)point
  • Index(es):
    • Date
    • Thread