×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    18

    how to handle find box event?

    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?

    Can some one help me? Thanks

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,144
    you could catch the Ok button in your offer keyevent function ( key code is EKeyDevice3) and call the function what you need in there.

    yucca

  3. #3
    Regular Contributor
    Join Date
    Mar 2004
    Location
    India
    Posts
    67

    Please look into my code

    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;
    }

    TKeyResponse CFetchContactsContainer::OfferKeyEventL(
    const TKeyEvent& aKeyEvent,
    TEventCode aType )
    {
    if(aType == EEventKeyDown)
    {
    switch ( aKeyEvent.iScanCode )
    {
    //case EStdKeyEnter:
    case EStdKeyDevice3:
    {
    //TInt n_ContactIndex = iListBox->CurrentItemIndex();
    TBuf<50> tb_ContactsNameBuf;
    //tb_ContactsNameBuf ItemText(n_ContactIndex) ;
    MDesCArray* itemList = iListBox->Model()->ItemTextArray();
    TInt alk=iListBox->CurrentItemIndex();
    tb_ContactsNameBuf.Copy(itemList->MdcaPoint(iListBox->CurrentItemIndex()));

    HERE I M LAUNCHING THE BROWSER AND I WANT TO ADD THE SELECTED ITEM PHONENO IN THE URL

    HBufC* param = HBufC::NewLC(300);
    param->Des().Copy(_L("4 "));
    param->Des().Append(m_tbStfUrlBuf);
    pAppUi->LaunchWapBrowswer1L( *param );
    CleanupStack::PopAndDestroy(); //cleanup
    }
    return EKeyWasConsumed;
    default:
    break;
    }
    }
    if ( aType != EEventKey ) // Is not key event?
    {
    return EKeyWasNotConsumed;
    }
    if ( iListBox )
    {
    if ( iFindBox )
    {
    TBool needRefresh( EFalse );
    //NB: Have overridden the functionality of
    //AknFind::HandleFindOfferKeyEventL( aKeyEvent, aType, this,iListBox, iFindBox, ETrue,needRefresh )
    if (CustomFindOfferKeyEventL( aKeyEvent, aType, this, iListBox, iFindBox, ETrue,needRefresh ) == EKeyWasConsumed )
    {
    if ( needRefresh )
    {
    iListBox->SetCurrentItemIndex(0);
    iListBox->HandleItemAdditionL();
    SizeChanged();
    DrawNow();
    }
    return EKeyWasConsumed;
    }
    }
    return iListBox->OfferKeyEventL( aKeyEvent, aType );
    }
    else
    {
    return EKeyWasNotConsumed;
    }
    }

    Yucca please guide my way through
    Thanks
    Alok
    Last edited by alokkumarsingh; 2004-08-06 at 11:27.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •