2 Replies Latest reply on Jun 26, 2008 11:24 AM by Rick-ety

    Container not repsecting min sizes for children


      I have a basic problem with HBox / HDividedBox (and other layouts) - see below code.

      Button 2 on right has minimum width and this is respected by the HDividedBox dragger - the button always get it's minimum width. However Button 1 on left, which is inside a HBox can get clipped when moving the dragger.

      It seems that HBox isn't constrained to have minimumWidth sufficient to always show it's children - or the HdividedBox is not respecting it. Surely there a way to do this? I've tried playing around with scroll bar policies etc but without luck.

      BTW I find it odd that Buttons don't automatically constrain min height/width to always so the label text (most other UI toolkits I've used before did this by default) - but that is another issue.....

      Thanks for any hints !

        • 1. Re: Container not repsecting min sizes for children
          matthew horn Level 3
          The min widths are enforced at the initial layout. What's happening, then, is that the user is dragging the divider and destroying that arrangement. So what you want to do is prevent the user from dragging the divider left so much so that the button gets clipped?

          You could do something like set the HBox's minWidth to the button's minWidth like this:

          <mx:HBox minWidth="{b1.minWidth}">
          <mx:Button id="b1" label="Button 1" minHeight="20" minWidth="60" width="100%"/>
          <mx:Button label="Button 2" minHeight="20" minWidth="60" width="100%"/>

          matt horn
          flex docs
          • 2. Re: Container not repsecting min sizes for children
            Rick-ety Level 1
            Thanks - you are correct that the layout is correct when app is initially started.

            I *could* hardcode the HBox width and this would work - but this would mean whenever any HBox child changed width I'd have to adjust it.....

            What I don't understand is why the HBox doesn't expose it's minimum size as the minimum dictated by the sum of min sizes of contained children and the various padding (the single button in this case).

            This is the normal behaviour I've seen on h/v box layouts in other UI toolkits - e.g. the C++ based, cross platform Qt http://doc.trolltech.com/4.4/layout.html

            Also why does HDividedBox respect the minimum widths of it's children - but HBox doesn't?