Can not enter letter in find box! (Help me please!)

Login to reply to this topic.
Sun, 2005-03-13 09:39
Joined: 2005-03-06
Forum posts: 34
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;
}

Sun, 2005-03-13 23:40
Joined: 2004-08-19
Forum posts: 112
Can not enter letter in find box! (Help me please!)
Set its focus with:

Code:
iFindBox->SetFocus (ETrue);

Bye,
 Gabor

Bye,
Gábor

Mon, 2005-03-14 19:36
Joined: 2005-03-06
Forum posts: 34
Thanks!
Thanks for replying! You are a good guy!
Fri, 2006-05-12 09:24
Joined: 2003-12-20
Forum posts: 3
Re: Can not enter letter in find box! (Help me please!)
djgtram, I love u!!!
  • Login to reply to this topic.