Problem with ListBox::updateContent() if ListBox not visible

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.

A very good point.

How about adding this method to the listbox:

void ListBox::visibilityChanged() { viewport->updateVisibleArea (true); }

That solves it.

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.

Ok, that’s an interesting one. How about at line 424 replacing this:

if (isVisible()) viewport->updateVisibleArea (true);


    viewport->updateVisibleArea (isVisible());


That’s what I suggested in the first post to solve the first problem.

[quote=“photon”]That’s what I suggested in the first post to solve the first problem.

Ah! Well great minds think alike!