Having searched and tried for hours now, this is my last resort.
Having a custom component class which has to go into a ListBox row.
Problem is that the rowNumber seems to wrap around in ListBoxModel’s call refreshComponentForRow (…)
(which gets called from private ListViewport) causing “alias” objects in the list view.
I found that this circumstance is dependent on the rowHeight itself.
When I decrease its size , wrap occurs proportional.
here is some code snip:
class ModulList : public ListBox,
public ListBoxModel
…
void ModulList::addItem()
{
++numRows;
updateContent();
}
ModulStrip * ModulList::addStrip()
{
ModulStrip *m = makeModulStrip();
modulArray.add(m); // seems to be redundant, however
m->setID(numRows);
return m;
}
void ModulList::paintListBoxItem( int rowNumber, Graphics& g, int width, int height, bool rowIsSelected )
{
return; // don’t needed - but pure virtual, so …
}
Component* ModulList::refreshComponentForRow (int rowNumber, bool isRowSelected, Component* existingComponentToUpdate)
{
if( rowNumber < getNumRows()){ // <-- this line seems necessary otherwise on creation it will get filled automagically up to "wrap number"
if (existingComponentToUpdate == 0)
existingComponentToUpdate = addStrip();
}
return existingComponentToUpdate;
}
Thanks
