×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Registered User
    Join Date
    Aug 2004
    Location
    Hungary
    Posts
    42

    Question EEventKey + listbox + search field

    Hi,

    I created a container class with listbox and search field. I implemented also the OfferKeyEventL(...) function to handle events created by key strokes in the search field.
    If i cancel from the text of the search field, the TEventCode of the OfferKeyEventL() setted to EEventKey and i can handle this event, if i write in the field, i got EEventKeyDown code but i don't have any EEventKey code. It seems that the framework handle the event in this case.
    According to the SDK documentation i should get EEventKeyDown, EEventKey, EEventKeyUp events. Where is the EEventKey?
    What i should to do?

    My relevant codes:


    my header file:

    class CMyAppView1Container : public CCoeControl
    {
    public:

    CMyAppView1Container();
    void ConstructL(const TRect& aRect, CMyAppView1* aParent);
    virtual ~CMyAppView1Container();
    void SizeChanged();

    TInt CountComponentControls() const;
    CCoeControl* ComponentControl(TInt aIndex) const;
    void Draw(const TRect& aRect) const;
    TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,
    TEventCode aType);

    private:

    void CreateListBoxL();
    void AddItemsToListBoxL();
    void DisplayFindBoxL();


    CAknSingleNumberStyleListBox* iListBox;
    CDesC16ArraySeg* iListBoxRows;
    CAknSearchField* iFindBox;

    CMyAppView1* iParent;


    };



    in the cpp the creation of the listbox and find pane:


    void CMyAppView1Container::CreateListBoxL()
    {
    iListBox = new (ELeave) CAknSingleNumberStyleListBox();
    iListBox->ConstructL(this);
    iListBox->SetContainerWindowL(*this);
    iListBox->SetRect( Rect() );

    iListBoxRows = new (ELeave) CDesC16ArraySeg( KStoreArrayLength );
    iListBox->Model()->SetItemTextArray( iListBoxRows );
    iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);

    iListBox->CreateScrollBarFrameL( ETrue );
    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL (
    CEikScrollBarFrame::EOff,
    CEikScrollBarFrame::EAuto );
    iListBox->ActivateL();
    iListBox->DrawNow();
    }


    void CMyAppView1Container::DisplayFindBoxL()
    {
    CAknFilteredTextListBoxModel* model =
    static_cast<CAknFilteredTextListBoxModel*>( iListBox->Model() );
    iFindBox = CAknSearchField::NewL( *this, CAknSearchField::ESearch,
    NULL, KAknExListFindBoxTextLength );
    CleanupStack::PushL(iFindBox);
    iListBox->SetContainerWindowL(*this);
    model->CreateFilterL( iListBox, iFindBox );
    CleanupStack::Pop(iFindBox);

    iFindBox->ActivateL();
    iFindBox->DrawNow();
    SizeChanged();
    }


    void CMyAppView1Container::ConstructL(const TRect& aRect, CMyAppView1* aParent)
    {
    CreateWindowL();
    SetRect(aRect);
    iParent = aParent;
    CreateListBoxL();
    AddItemsToListBoxL();
    DisplayFindBoxL();
    ActivateL();
    }


    TKeyResponse CMyAppView1Container::OfferKeyEventL(
    const TKeyEvent& aKeyEvent, TEventCode aType)
    {
    if (aType != EEventKey)
    {
    return EKeyWasNotConsumed;
    }

    [...]

    }

  2. #2
    Registered User
    Join Date
    Aug 2004
    Location
    Hungary
    Posts
    42

    Re: EEventKey + listbox + search field

    The solution for my problem:

    - I derived my container class also from MCoeControlObserver,
    - i declared CAknListBoxFilterItems* iFilterItems class variable,
    - i created the iFilterItems:

    CAknFilteredTextListBoxModel* model =
    static_cast<CAknFilteredTextListBoxModel*>( iListBox->Model() );
    iFilterItems = model->Filter();
    iFilterItems->SetObserver(this);

    - i implemented the HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType) function.

    In this function just i could handle all CAknSearchField related events.

  3. #3
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    107

    Re: EEventKey + listbox + search field

    Hi your Article is somewht related to what i have done , I am actually interested in find the String from reverse side for eg if i have an entry
    "bharat" in my list box then i must type tarahb in reverse order still it cud filter the entry bharat

    from your article i didnt get sum points
    1> How to did your iFilterItems using new (ELeave) or the piece of code
    2> Where did you inserted tht piece of code Did you remove the line
    model -> CreateFilterL()
    3> Wht did you meant by last line I could handle all the CAknSearchField events

    I hope you will help me regarding this a pseudo code will also be helpful
    you can mail me at bharat.uppal@wipro.com

    Thanks in advance
    Bharat Uppal

  4. #4
    Super Contributor
    Join Date
    May 2005
    Location
    Hyderabad,India
    Posts
    704

    Re: EEventKey + listbox + search field

    Hi,

    just go to the lookup example in symbian site. It'll helpful for u.


    regards,
    eswar

  5. #5
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    107

    Re: EEventKey + listbox + search field

    Hi eswar

    I had gone thru tht look up example but most of the things are done manually i just want to perform a reverse string search

    i mean if entry has bharat i should provide the keys as tarahb

    but i want to know whether this is possible with sum api 's as i was able to do it with manual approach I mean is there any flag tht allows reverse search in CAknSearchfield

  6. #6
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: EEventKey + listbox + search field

    hi bharat,

    Follow the Search sequence used for the list . Reverse ur text in accordence to it and then search for the required string in the list.

    Regards,
    Mateen maldar

  7. #7
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    107

    Re: EEventKey + listbox + search field

    Matteen Thanks for your reply I had already done tht n i am successful but all you said was done manually i mean we have to overide offerkeyeventL but is there not any way tht CAknSearchfield will auto matically handle the reverse operation i mean by default it is matching from the first alphabet from left to right is there no way tht comparison is done from right to left.

    thanks in advance

  8. #8
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: EEventKey + listbox + search field

    hi,
    CAknSearchfield supports only this Operations for the Search ..
    TSearchFieldStyle {
    ESearch, EInput, EUrl, EPhone,
    EPlain, EPopup, EPinb, EClockApp,
    EFixed, ESearchWithoutLine
    }

    There is no way to do it automatically .Use manual process of "c" Programming to search and then make it relavent to ESearch after making it in mapped to the list item.

    Regards,
    Mateen Maldar

  9. #9
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    107

    Re: EEventKey + listbox + search field

    Can you just tell me in short what doea those Eplain Epinb ESearchWithoutLIne do

  10. #10
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: EEventKey + listbox + search field

    hi,

    Check the Sdk Documentation for the explanation but it is not clear ..

    Wht i think abt this is

    Eplain - will search for a simple string but not a random search

    Epinnb- has to check for the real time behaviour.

    ESearchWithoutLIne - Seaches for the string with without line

    These has to checked for exact explanation as the sdk documentation is not having a proper explanation for this...

    U can try it out as an R&D stuff well it requires me some time to look at it.

    Regards,
    Mateen Maldar

  11. #11
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    107

    Re: EEventKey + listbox + search field

    Thanks for the reply please give your email id so tht we can be in touch and exchange doubts if u r comfortable

    thank you

  12. #12
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: EEventKey + listbox + search field

    hi,

    check my profile form the forum nokia and will get the email id of mine

    i'm online on msn always,

    Regards,
    Mateen maldar

  13. #13
    jp4symbian
    Guest

    Re: EEventKey + listbox + search field

    Thanks a lot egeri!!!

    Your solution has been very useful to me...
    I was not able to get the Key Events of the Search Field in OfferKeyEvent...
    Was searching and doing R&D since last 2 days..

    Finally found your post and now using your code, i can handle them in HandleControlEventL!!!

    Thanks a million!!!

  14. #14
    Regular Contributor
    Join Date
    May 2007
    Posts
    65

    Smile Re: EEventKey + listbox + search field

    Yeah thanks egeri! I also just had this problem and couldn't understand why my OfferKeyEventL wasn't being called with EEventKey, but yet the find box was still working.

    Interestingly you do get called if you press delete in the searchbox, just not if you type any letter characters.

    So is this a bug, or a feature? Does it mean that the SearchListBox example code on the wiki is wrong? I used that as a template, and if you comment out the call to AknFind::HandleFindOfferKeyEventL then the code still works (apart from delete key)!

  15. #15
    Regular Contributor
    Join Date
    Oct 2004
    Location
    India
    Posts
    138

    Red face Re: EEventKey + listbox + search field

    Hey, i got the same problem and tried the same solution.
    But, this does not work for me.
    Because, the function "HandleControlEventL" does not get called at all.

    br,
    - kc

Similar Threads

  1. Search Field
    By vvsnaresh in forum Symbian
    Replies: 4
    Last Post: 2005-08-30, 07:56
  2. how to lodge a list with search field into window?
    By kernj in forum Symbian User Interface
    Replies: 1
    Last Post: 2005-08-26, 00:36
  3. "Series 60" contacts search field
    By keisala in forum Symbian User Interface
    Replies: 4
    Last Post: 2004-09-10, 12:09
  4. How to remove the border of search field
    By jntu_hareesh in forum Symbian User Interface
    Replies: 0
    Last Post: 2004-06-30, 08:24
  5. Change Search Field Font
    By Blkangel in forum Symbian
    Replies: 0
    Last Post: 2004-02-08, 16:12

Posting Permissions

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