ListBox bug?

I would expect that ListBox::setSelectedRows () would have some effect on the ‘lastRowSelected’ value.

I’m storing the selection of a ListBox, so that it can be restored when a list reappears. Applying the selection to the ListBox is fine, but then keyboard control always resumes from the top. I understand that it’s tricky to judge where to go from, but surely the first or last in the set would be reasonable enough?

At the very least, if there’s only one row in the selection, it is logical for lastRowSelected to be given that value. Otherwise keyboard control does not function as expected.

I’d do selectRow(selection[0]) followed by setSelectedRows(selection), but my selectedRowsChanged() needs to update selection with the current choices, so that won’t work.

Good point. How about just this change:

[code]void ListBox::setSelectedRows (const SparseSet& setOfRowsToBeSelected)
selected = setOfRowsToBeSelected;
selected.removeRange (totalItems, INT_MAX - totalItems);

if (! isRowSelected (lastRowSelected))
    lastRowSelected = getSelectedRow (0);