Button frame to screen rect
-
What would be the easiest way to convert the frame rect of a button in
a window to a screen rect ?
My goal is to have a window animate out from this button.
For some reason (perhaps lack of coffee), i'm not able to wrap my
brain around the various convert methods for views.
Thanks!
Jack -
On 13 Apr 2010, at 5:30 AM, Jack Carbaugh wrote:
> What would be the easiest way to convert the frame rect of a button in a window to a screen rect ?
Search the documentation for symbols beginning with "convert"; among the results:
> convertBaseToScreen:
>
> Converts a given point from the window’s base coordinate system to the screen coordinate system.
>
> - (NSPoint)convertBaseToScreen:(NSPoint)point
>
> Parameters
>
> point
> The point expressed in the window’s base coordinate system.
>
> Return Value
>
> point expressed in screen coordinates.
>
> Availability
>
> • Available in Mac OS X v10.0 and later.
It converts NSPoints, but you can do the math. You may want to start with the bounds rect of the button, and use -[NSView convertPoint:toView:] with the second argument nil; it will keep working if you ever move the button to an enclosing view.
— F -
Thanks for your help.
From this then, I would use the origin point ... of the bounds or
frame of the button rect, which would give me the equivalent in screen
coordinates and then just adjust the width/height as necessary for my
window ?
Again, my thanks
On Apr 13, 2010, at 10:42 AM, Fritz Anderson wrote:
> On 13 Apr 2010, at 5:30 AM, Jack Carbaugh wrote:
>
>> What would be the easiest way to convert the frame rect of a button
>> in a window to a screen rect ?
>
> Search the documentation for symbols beginning with "convert"; among
> the results:
>
>> convertBaseToScreen:
>>
>> Converts a given point from the window’s base coordinate system to
>> the screen coordinate system.
>>
>> - (NSPoint)convertBaseToScreen:(NSPoint)point
>>
>> Parameters
>>
>> point
>> The point expressed in the window’s base coordinate system.
>>
>> Return Value
>>
>> point expressed in screen coordinates.
>>
>> Availability
>>
>> • Available in Mac OS X v10.0 and later.
>
> It converts NSPoints, but you can do the math. You may want to start
> with the bounds rect of the button, and use -[NSView
> convertPoint:toView:] with the second argument nil; it will keep
> working if you ever move the button to an enclosing view.
>
> — F


