Can not enter letter in find box! (Help me please!)
| Sun, 2005-03-13 09:39 | |
|
Hello all!
I have read Lookup example at www.symbian.com and created the find box. But I can not enter letter (such as 'a', 'b'...) in find box. How can I find by letter in listbox??? I am a newbie in Symbian so don't know mayny things. Some kinds help me, please! I wrote this code to create find box: void CMy_ListboxContainer::ConstructL(const TRect& aRect) { CreateWindowL(); //list box iListBox = new( ELeave ) CAknSingleStyleListBox(); iListBox->ConstructL(this); iListBox->SetContainerWindowL(*this); iItemArray= InitListBoxData(); iListBox->Model()->SetItemTextArray(iItemArray); iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray); //The model does not own the item array — you must maintain a pointer to it and free it explicitly before your program exits iListBox->HandleItemAdditionL(); //find box iFindBox = CAknSearchField::NewL(*this, CAknSearchField::EPopup, NULL, 20);//20 is text limit //CAknFilteredTextListBoxModel* model= (CAknFilteredTextListBoxModel *)(iListBox->Model()); CAknFilteredTextListBoxModel* model= static_cast<CAknFilteredTextListBoxModel*>(iListBox->Model()); CleanupStack::PushL(iFindBox); model->CreateFilterL(iListBox, iFindBox); CleanupStack::Pop(iFindBox); if ( iFindBox ) { // Popup findbox is not shown when listbox display initial. iFindBox->MakeVisible( ETrue ); iFindBox->ActivateL(); } SetRect(aRect); ActivateL(); } CDesCArray* CMy_ListboxContainer::InitListBoxData() { _LIT(KFormatItem,"\tItem %d\t\t"); CDesCArray* aItemArray= new (ELeave) CDesCArrayFlat(4);//4 is granularity _LIT(KTestItem,"\tAnh yeu\t\t"); aItemArray->AppendL(KTestItem); for(int i=0;i<4;i++) { TBuf<20> s; s.Format(KFormatItem,i); aItemArray->AppendL(s); } return aItemArray; } TKeyResponse CMy_ListboxContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) { if (aType != EEventKey) { return EKeyWasNotConsumed; } if (iFindBox) { if (iFindBox) { //return iFindBox->OfferKeyEventL(aKeyEvent, aType); TBool aNeedRefresh(EFalse); if ( AknFind::HandleFindOfferKeyEventL(aKeyEvent, aType, this, iListBox, iFindBox, ETrue, aNeedRefresh)== EKeyWasConsumed ) { if (aNeedRefresh) { SizeChanged(); DrawNow(); } return EKeyWasConsumed; } } return iListBox->OfferKeyEventL(aKeyEvent, aType); } return EKeyWasNotConsumed; } |
|






Forum posts: 112
Bye,
Gabor
Bye,
Gábor
Forum posts: 34
Forum posts: 3