Skip navigation.
 
mlRe: Why does my custom view grow in the wrong direction?
FROM : Matt Neuburg
DATE : Tue Jul 04 23:50:05 2006

On Tue, 4 Jul 2006 09:01:23 -0700, Tito Ciuro <<email_removed>> said:
>Hello,
>
>I have a custom NSView that is not behaving the way I expected. I
>return YES in isFlipped, and when I change the height of the view
>like this:
>
>- (void)adjustContainerWithNewHeight:(float)newHeight
>{
>    NSRect containerFrame = [self frame];
>    if (newHeight > containerFrame.size.height) {
>        containerFrame.size.height = newHeight;
>        [self setFrame:containerFrame];
>    }
>}
>
>the view grows "upward" (the origin moves up), as I would expect if
>isFlipped == NO. Any other operations, such as placing subviews at a
>particular point behaves fine, that is, increasing origin.y goes
>downward.
>
>Why is that? How should I grow the view while honoring its origin?


"isFlipped" here is a red herring. Your frame is your position in the larger
world around you, and uses the coordinate system of that larger world. For
example, a window's frame is in screen coordinates. A button's frame is in
its superview's coordinates. This is completely unaffected by "isFlipped",
which is about something else entirely. See:

...Cocoa/Conceptual/CocoaViewsGuide/Coordinates/chapter_3_section_3.html

So, your frame's origin is still the lower left, and it is growing in the
normal way - its height is increasing and its lower left is staying the same
(because you didn't change it). To make it grow "downward", you'll have to
adjust its origin's y value at the same time that you change its height. m.

--
matt neuburg, phd = <email_removed>, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>

Related mailsAuthorDate
mlWhy does my custom view grow in the wrong direction? Tito Ciuro Jul 4, 18:01
mlRe: Why does my custom view grow in the wrong direction? Matt Neuburg Jul 4, 23:50
mlRe: Why does my custom view grow in the wrong direction? Tito Ciuro Jul 5, 00:41