Problem: 1615666

Title: (TTextListView -DoKeySelection) Wrong for empty list

Received: Dec 27 1996 1:15PM


When typing keys in an empty list the keyselectionbehaviour calls DoKeySelection. This call starts with setting the default to GetItemIndexOrdered(1). Later on it calls SelectItem. In case the list is empty this is wrong!
void TTextListView::DoKeySelection(const CStr255& selectionString)
{
        CStr255 itemText;
        short itemIndex;
        short lastItemIndex = GetItemIndexOrdered(1);
        for (short i = 1; i <= fNumOfRows; i++)
        {
                itemIndex = GetItemIndexOrdered(i);
                GetItemText(itemIndex, itemText);
                itemText.Delete(selectionString.Length() + 1,
itemText.Length() -
selectionString.Length());
                lastItemIndex = itemIndex;
                if (itemText >= selectionString)
                        break;
        }
        this->SelectItem(lastItemIndex, FALSE, TRUE, TRUE);
        this->ScrollSelectionIntoView(TRUE);
} // TTextListView::DoKeySelection

Fix:

UGridView.cp: Added a test of fNumOfRows inside TTextListView::DoKeySelection that shortcircuits the entire function if there are no rows in the list.