I have a ListBox as tab in a TabbedComponent. Actions on other tabs insert items into the ListBox. After an item has been added ListBox::updateContent() gets called but at this moment the ListBox is not visible and so the ListViewport isn’t updated. If I switch to the tab contaning the ListBox the new items aren’t shown. I need to trigger an ListViewport::updateVisibleArea(…) by resizing the window to get them shown.
void ListBox::updateContent()
{
[...]
if (isVisible())
viewport->updateVisibleArea (true);
[...]
}
To solve this the ListViewport::updateVisibleArea(…) needs to be called too when the ListBox is not visible or perhaps set a flag like ‘needViewportUpdate’ and check it when the ListBox become visible again to do the update then.
I found something that still can break it. I do a ListBox::setVerticalPosition(1) after I added and item an called ListBox::updateContent() while the ListBox is not visible. Due to the not executed ‘viewport->updateVisibleArea(true)’ in ListBox::updateContent() the viewport scrolls to the wrong position because it operates on a wrong height.