2 Replies Latest reply on May 4, 2009 12:19 PM by JoshBeall

    How do I get constraints to adjust when scroll bars are shown?

    JoshBeall Level 1

      Hi All,

       

      I've got the following page setup, with constraints that causes everything (datagrid, content grid, etc.) to grow and shrink when the user adjusts the size of the window.

       

      http://www.joshbeall.com/personal/flexconstraints1.png

       

      Now, the problem is, if there are enough controls on the page to require vertical scrolling (e.g., if I resize the window, or change to another state that has more controls on the page), and it adds vertical scroll bars, the controls are not reduce in size, which means that some of them are now underneath the vertical scrollbar, which causes a horizontal scrollbar to appear.  Like this:

       

      http://www.joshbeall.com/personal/flexconstraints2.png

       

      Right now the constraint on all the controls is right="10", and what I want is for it to be 10 pixels from the right of the usable canvas--so if a scrollbar appears, it should be 10 pixels from the left edge of the scrollbar.  If there is no scrollbar, it should be 10 pixels from the edge of the viewport.

       

      This is the way the browser treats scrollbars.  How do I get this behavior in Flex?

       

        -Josh

        • 1. Re: How do I get constraints to adjust when scroll bars are shown?
          Michael Borbor Level 4

          You could add a right padding to your controls to cause them to stay 

          away from the scrollbars, remember that scrollbars aren't taken into 

          account during controls layout.

           

          Sincerely,

           

          Michael

           

          El 04/05/2009, a las 9:42, JoshBeall <forums@adobe.com> escribió:

           

          >

          Hi All,

          >

          I've got the following page setup, with constraints that causes 

          everything (datagrid, content grid, etc.) to grow and shrink when 

          the user adjusts the size of the window.

          >

          http://www.joshbeall.com/personal/flexconstraints1.png

          >

          Now, the problem is, if there are enough controls on the page to 

          require vertical scrolling (e.g., if I resize the window, or change 

          to another state that has more controls on the page), and it adds 

          vertical scroll bars, the controls are not reduce in size, which 

          means that some of them are now underneath the vertical scrollbar, 

          which causes a horizontal scrollbar to appear.  Like this:

          >

          http://www.joshbeall.com/personal/flexconstraints2.png

          >

          Right now the constraint on all the controls is right="10", and 

          what I want is for it to be 10 pixels from the right of the usable 

          canvas--so if a scrollbar appears, it should be 10 pixels from the 

          left edge of the scrollbar.  If there is no scrollbar, it should be 

          10 pixels from the edge of the viewport.

          >

          This is the way the browser treats scrollbars.  How do I get this 

          behavior in Flex?

          >

            -Josh

          >

          • 2. Re: How do I get constraints to adjust when scroll bars are shown?
            JoshBeall Level 1

            Yes, I know that--I was wondering if there was a way to get the constraints to observe the presence (or absence) of scrollbars, or if we just have to do as you mentioned, and add enough padding that the scrollbars will be in an area with whitespace.  In other words, we have to always reserve space for the scrollbars, even when they aren't necessary, instead of letting Flex dynamically resize the items on the canvas based on the constraints we've given (which, I thought, was the whole point of using constraints).

             

            -Josh

             

            Michael Borbor, on May 4, 2009 7:48 AM

            You could add a right padding to your controls to cause them to stay  away from the scrollbars, remember that scrollbars aren't taken into  account during controls layout.