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


#1

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.


#2

A very good point.

How about adding this method to the listbox:

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


#3

That solves it.


#4

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.


#5

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

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

with

    viewport->updateVisibleArea (isVisible());

?


#6

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


#7

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

Ah! Well great minds think alike!


#8