Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home for chromium.org
« Groups Home
Cocoa PSA: Do not use -[NSView convert[Point|Rect][To|From]Ba se:]
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Avi Drissman  
View profile  
 More options Feb 25 2010, 12:18 am
From: Avi Drissman <a...@chromium.org>
Date: Wed, 24 Feb 2010 21:18:26 -0800
Local: Thurs, Feb 25 2010 12:18 am
Subject: Cocoa PSA: Do not use -[NSView convert[Point|Rect][To|From]Base:]

http://code.google.com/p/chromium/issues/detail?id=36485

Briefly: Suppose you want to do a conversion to or from an NSView's
coordinate system to the coordinate system of its window. NSView has a
tempting set of methods:

convertPointFromBase:
convertPointToBase:
convertRectFromBase:
convertRectToBase:
convertSizeFromBase:
convertSizeToBase:

DO NOT USE THEM!

If you want to convert to/from the window's base coordinate system, use the
original -convert[xx]:[to|from]View: and pass in a nil view.

What those "base" calls do is a conversion to the "base" coordinate system
which isn't the "window base" coordinate system. This will not get you the
coordinates you want. Don't use them. (The "base" coordinate system has to
do with resolution independence; go look it up.)

The confusion is compounded by the "base" methods on NSWindow:
convertBaseToScreen: and convertScreenToBase:. Those are conversions betwwen
the window base system and screen coordinates, and are what you want to use
for that case.

Avi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Avi Drissman  
View profile  
 More options Mar 15 2010, 3:07 pm
From: Avi Drissman <a...@chromium.org>
Date: Mon, 15 Mar 2010 14:07:31 -0500
Local: Mon, Mar 15 2010 3:07 pm
Subject: Re: Cocoa PSA: Do not use -[NSView convert[Point|Rect][To|From]Base:]

As a follow-up, I'm finding with surprising frequency that code is
converting coordinates to the window's *contentView*'s coordinate system
when the intent is to convert it to the window's coordinate system. (For
example, I've seen code that converts a point from a view's coordinate
system to the window's *content view* coordinate system, and then turns
around and converts it from the *window*'s coordinate system to global
space.)

This might accidentally work today, but fails horribly under resolution
independence. If you need to convert to window coordinate space,
please *actually
do so*. (Use convertXXX:toView:nil as described earlier.) Using the window's
content view as a target for convertXX:toView: is a very bad idea.

Avi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »