Detecting if UIComponent has active scrollbars

I have a TileList in flex and need to determine if scrollbars are shown or not, so I can resize the items it lays out.

The ScrollPolicy is set to automatic, but I need a variable like CurrentScrollPolicy that will change from on to on depending on the content.

thanks

0


a source to share


4 answers


Thanks eBuildy, your right!

I created an example that also takes into account the fact that scrollbars are hidden when not needed, rather than revert to zero:



   public class CustomTileList extends TileList
{

    public function CustomTileList()
    {
        super();
    }

    /**
     * Returns true if the vertical scroll bar is displayed
     * @return Boolean
     *
     */
    public function hasVerticalScrollBar():Boolean
    {
        if (super.verticalScrollBar == null || super.verticalScrollBar.visible == false)
            return false;
        return true;
    }

}

      

Thanks for the help.

+5


a source


Or, if you don't want to override the list, you can have something like

if(listInstance.mx_internal::scroll_verticalScrollBar != null){...}

      



Hooray!

+4


a source


I used a very simple trick to get around this problem. Set the scroll position to the maximum, as it will always be zero, if there is no scroll, if you are checking it and it is above zero, add the height to the element because there should be scrollbars.

yourControl.verticalScrollPosition = yourConrol.maxVerticalScrollPosition;

for (var i:int=0; i <= yourControl.verticalScrollPosition ;i++)
{
     yourControl.height = yourControl.height+16;
}

      

+1


a source


You need to check verticalScrollBar. If its value is null, then there is no scrollbar. If it is not null, then there is a scrollbar.

0


a source







All Articles