I try to implement find box in list box, and when some item is find, I want to envoke some action. There should be 2 ways to do tath. ONe is use up and down arror to find the item, and click OK button, but I can not catch the key down event from the list box.
Another way is type in the find box, and when one match is found, envoke the event.
How to implement this?
Hi Yucca,
I am implementing the the listbox with Find Box using the lookup code , i m facing problem in offer keyevent function .
My problem is like assume that when first time listbox opens it shows "tt1" item as a first item from contacts db , then if i write "A" in find box it shows contacts with "A" . But when i select first item starting with "A" by clicking ok , then current item index is shown is zero and the data on that item is showing the data, of first item when listbox is intially created that is "tt1"
My code goes like this...
TKeyResponse CFetchContactsContainer::CustomFindOfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType, CCoeControl* /*aListBoxParent*/, CEikListBox* /*aListBox*/, CAknSearchField* /*aSearchField*/, TBool /*isFindPopup*/, TBool &aNeedRefresh)
{
if ( aType != EEventKey ) // Is not key event?
{
return EKeyWasNotConsumed;
}
TBuf<30> k;
if (aKeyEvent.iCode==EKeyBackspace)
{
iFindBox->GetSearchText(k);
if (k.Length()>=1) k.Delete(k.Length()-1,1);
iFindBox->SetSearchTextL(k);
QueryContactsDbL(k,ETrue); //Slow step - selection got wider!
aNeedRefresh=ETrue;
}
TChar charCode(aKeyEvent.iCode);
if (charCode=='*') charCode='+';
if (((charCode>='0') && (charCode<='9')) || (charCode=='+'))
{
iFindBox->GetSearchText(k);
if (k.Length()<30)
{
k.Append(charCode);
iFindBox->SetSearchTextL(k);
QueryContactsDbL(k,EFalse); //Faster!
aNeedRefresh=ETrue;
}
}
if (aNeedRefresh)
{
return EKeyWasConsumed;
}
return EKeyWasNotConsumed;
}