Small ScrollBar fix


#1

When I do the following:

1) Create a ScrollBar object

2) Set its desired position and size with setBounds() (which is not meant to change later)

3) Add it to its parent component (which has a LookAndFeel where areScrollbarButtonsVisible() always returns false)

 

The ScrollBar appears with the button on its ends despite the fact that the (inherited) LookAndFeel says they shouldn't be there.

This happens because creation/destruction of those buttons according to the LookAndFeel is made by the ScrollBar only upon resize. In general, this is a good assumption as ScrollBar objects get resized a lot. In my particular case, that does not happen at all and thus the problem shows up.

I have fixed this corner case by simply adding this:

void ScrollBar::parentHierarchyChanged()
{
    lookAndFeelChanged();
}

 

So that every time the ScrollBar is added to a parent component , the possibility that its inherited LookAndFeel can possibly have changed is taken into account properly.


#2

Fixed, thanks for bringing it up!