Bug within the ListBox class

Hey Jules
I think I have found a bug within the ListBox class.
When changing a ListBox’s content and calling ListBox::updateContent() the display only seems to update correctly if you are setting a different number of rows.

In my app, I’m updating a ListBox by passing its ListBoxModel object a StringArray containing the text for the rows. However calling updateContent() after passing this StringArray only seems to do anything when the StringArray is of a different size to previously, regardless of whether the Strings have changed at all. The display will only update when you click on a row again.

The docs explain that that method only forces a repaint if the number of rows change. I think it’s main use is to force a refresh of any custom components you might have.

If you know what rows have changed you can call ListBox::repaintRow (int rowNumber) to save a few CPU cycles but I think calling repaint() will just dirty them all and force a full repaint. Does this work for you?

Well, no, not a bug - updateContent() does exactly what its comment says, and that doesn’t include calling repaint().

There’s no way for the listbox to know whether something has changed that really does require all the rows to be repainted, so it leaves that decision up to you. In most places, you’ll probably want to call repaint() as well as updateContent(), but I’ve not made it do so automatically, as you might have more optimal code that only repaints particular rows that have changed.

Calling repaintRow() on each row works fine.