Hello, all.
The gross symptom: TableListBox::refreshComponentForCell is called with inconsistent values - it’s as if Juce just moves around the actual component as it finds convenient. This makes it difficult if you have a reasonably smart component in the cell.
Here’s a code fragment (with random cruft removed for easy reading).
Component* TableController::refreshComponentForCell(int row, int columnId,
bool isRowSelected,
Component* existing) {
int column = columnId - 1; // To account for the 1 we added above.
TableLabel* text = dynamic_cast<TableLabel*>(existing);
if (!text) {
text = new TableLabel(this, column, row);
} else {
DCHECK_EQ(column, text->col_); // FAILS!
DCHECK_EQ(row, text->row_);
}
In other words, the first time I see this component, it’s at one row, columnID location - but if I scroll around in the TableListBox, I’ll see that same component again, but with a different row and columnId.
This is rather unintuitive, and it also makes it pretty hard if, for example, you want to attach that component to some other thing in your program.
In my case, these TableLabels also update a GUI object elsewhere in the program, so if I scroll around in the TableListBox and then edit a field, the results are thrown into the wrong place.
I haven’t figured out how to fix this neatly in my code yet - I can’t just create a new TableLabel, because then I drop out of editing mode, preventing the user from editing.
Thoughts?