• 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: Why does my custom view grow in the wrong direction?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does my custom view grow in the wrong direction?


  • Subject: Re: Why does my custom view grow in the wrong direction?
  • From: Matt Neuburg <email@hidden>
  • Date: Tue, 04 Jul 2006 14:50:05 -0700
  • Thread-topic: Why does my custom view grow in the wrong direction?

On Tue, 4 Jul 2006 09:01:23 -0700, Tito Ciuro <email@hidden> 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@hidden, <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>



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Why does my custom view grow in the wrong direction?
      • From: Tito Ciuro <email@hidden>
  • Prev by Date: Re: performKeyEquivalent on NSTextField subclass
  • Next by Date: Re: sort descriptor optimization
  • Previous by thread: Why does my custom view grow in the wrong direction?
  • Next by thread: Re: Why does my custom view grow in the wrong direction?
  • Index(es):
    • Date
    • Thread