Code: Select all
/*************************************************************************
Search the list for an item with the specified text
*************************************************************************/
ListboxItem* Listbox::findItemWithText(const String& text, const ListboxItem* start_item)
{
// if start_item is NULL begin search at begining, else start at item after start_item
size_t index = (!start_item) ? 0 : (getItemIndex(start_item) + 1);
while (index < d_listItems.size())
{
// return pointer to this item if it's text matches
if (d_listItems[index]->getText() == text)
{
return d_listItems[index];
}
// no matching text, advance to next item
else
{
index++;
}
}
// no items matched.
return 0;
}
I think is no logical to skip start_item in this function. For example:
pCombo->findItemWithText(pCombo->getText(),pCombo->getListboxItemFromIndex(0)); give different result as
pCombo->findItemWithText(pCombo->getText(), NULL); The solution is delete + 1 from first line in function.
