×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    23

    HandleListBoxEventL never gets called - can someone take a quick look? :) I'm lost.

    OK,

    I been hitting my head againts a wall for a few days now.

    This is what I want to do:
    - I have a CAknSingleGraphicPopupMenuStyleListBox
    - I want to scroll one page at a time by hitting the left/right arrows keys

    Doing the above shouldn't be difficult, but I can't seem to capture the key events in the listbox.

    OK, so in my view class (the container) I have the following:

    Code:
    void MyAppView::ConstructL( const TRect& aRect ) {
    ...
        cList = new( ELeave ) CAknSingleGraphicPopupMenuStyleListBox;
        
        // Initialization of cList, and CAknPopupList that contains the cList
        
        cList->SetListBoxObserver(this);
    ...
    }
    
    // Never gets called
    void MyAppView::HandleListBoxEventL(CEikListBox* aListBox,TListBoxEvent aEventType) {
    
    _LIT( KBusy, "I am here2-1..." );
    CEikonEnv::Static()->BusyMsgL(KBusy); 
    
    }
    
    // Gets called
    TKeyResponse MyAppView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) {
    
    //_LIT( KBusy, "I am here3-1..." );
    //CEikonEnv::Static()->BusyMsgL(KBusy); 
    
    return cList->OfferKeyEventL(aKeyEvent, aType);
    
    //return EKeyWasNotConsumed;
    }
    The .h file for the view (container)
    Code:
    class MyAppView : public CCoeControl, MEikListBoxObserver
        {
    public:
       void HandleListBoxEventL(CEikListBox* aListBox,TListBoxEvent aEventType);
       TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
    ...
    private:
       CAknSingleGraphicPopupMenuStyleListBox* cList;
    In my UI class I add the view (container) to the stack:

    Code:
    AddToStackL(iAppView);
    OfferKeyEventL works fine, but HandleListBoxEventL is never called.

    I must be missing something obvious? someone put me out of my misery :)
    Last edited by marquk; 2009-01-26 at 18:06.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,750

    Re: HandleListBoxEventL never gets called - can someone take a quick look? :) I'm los

    You may try if SetFocus helps.

  3. #3
    Registered User
    Join Date
    Jul 2006
    Posts
    23

    Re: HandleListBoxEventL never gets called - can someone take a quick look? :) I'm los

    Quote Originally Posted by wizard_hu_ View Post
    You may try if SetFocus helps.
    Thanks for the help - tried it but still no key events in HandleListBoxEventL.

  4. #4
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: HandleListBoxEventL never gets called - can someone take a quick look? :) I'm los

    You wont get keyevents in the HandleListBoxEventL, the only key event will be when the middle nav button is pressed or the enter key is pressed, thats it.
    Download Symbian OS now! [url]http://developer.symbian.org[/url]

  5. #5
    Registered User
    Join Date
    Jul 2006
    Posts
    23

    Re: HandleListBoxEventL never gets called - can someone take a quick look? :) I'm los

    Quote Originally Posted by Paul.Todd View Post
    You wont get keyevents in the HandleListBoxEventL, the only key event will be when the middle nav button is pressed or the enter key is pressed, thats it.
    really? :shock: I thought all key presses would be registered within the listbox, specially the arrow keys (as the up/down are used to go up/down the list) :S. How do you suggest I capture the left/right key presses within the listbox?

  6. #6
    Registered User
    Join Date
    May 2007
    Location
    Poland
    Posts
    606

    Re: HandleListBoxEventL never gets called - can someone take a quick look? :) I'm los

    Hello,
    in OfferKeyEventL of your CCoeControl class catch arrows using this code:
    Code:
    	if (aKeyEvent.iCode==EKeyLeftArrow)
    		{
    		// write here your code for selecting previous or next item in listbox
    		return EKeyWasConsumed;
    		}
    	if (aKeyEvent.iCode==EKeyRightArrow)
    		{
    		// write here your code for selecting previous or next item in listbox
    		return EKeyWasConsumed;
    		}
    good luck

  7. #7
    Registered User
    Join Date
    Jul 2006
    Posts
    23

    Re: HandleListBoxEventL never gets called - can someone take a quick look? :) I'm los

    doesn't seem to work - it only catches key presses on the main view of the application, as soon as I pop-up the list no events are caught while on the list or while going through any of the menus. Any ideas?

    Quote Originally Posted by nuker85 View Post
    Hello,
    in OfferKeyEventL of your CCoeControl class catch arrows using this code:
    Code:
    	if (aKeyEvent.iCode==EKeyLeftArrow)
    		{
    		// write here your code for selecting previous or next item in listbox
    		return EKeyWasConsumed;
    		}
    	if (aKeyEvent.iCode==EKeyRightArrow)
    		{
    		// write here your code for selecting previous or next item in listbox
    		return EKeyWasConsumed;
    		}
    good luck

  8. #8
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: HandleListBoxEventL never gets called - can someone take a quick look? :) I'm los

    When I looked at this question I was stumped by the fact you are using both a listbox control and a popup list.

    Views use container controls, popup lists are designed to work almost like a modal dialog, but specifically for a list. Unless you inherit from the popup list and add your own key event handler (OfferKeyEventL) you will not get the events.

    So where are you using CAknPopupList?
    Download Symbian OS now! [url]http://developer.symbian.org[/url]

  9. #9
    Registered User
    Join Date
    Jul 2006
    Posts
    23

    Smile Re: HandleListBoxEventL never gets called - can someone take a quick look? :) I'm los

    Quote Originally Posted by Paul.Todd View Post
    When I looked at this question I was stumped by the fact you are using both a listbox control and a popup list.

    Views use container controls, popup lists are designed to work almost like a modal dialog, but specifically for a list. Unless you inherit from the popup list and add your own key event handler (OfferKeyEventL) you will not get the events.

    So where are you using CAknPopupList?
    Thanks for the clarification, I think the slight confusion comes from my inexperience of Symbian programming (quite new to it), so I am grateful for your patience.

    In the code I pasted in my original post, I use the CAknPopupList in the view constructor to contain the cList. Latter on in the code I have a function that once called it executes popupList->ExecuteLD(). Indeed the CAknPopupList looks like a modal dialog, and thats why I like it :) Thought it looked better than a normal list. OK, so do you think I should be inheriting from CAknPopupList, and then handle all the CAknPopupList events in my OfferKeyEventL function? I can try that, any pitfalls that I should be aware of?

  10. #10
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: HandleListBoxEventL never gets called - can someone take a quick look? :) I'm los

    As the documentation says
    /**
    * Executes the pop-up selection list. Function returns when the user have
    * accepted or cancelled the pop-up.
    *
    * @return @c ETrue if the popup was accepted. @c EFalse if
    * the popup was cancelled.
    */
    IMPORT_C TBool ExecuteLD();
    Short answer is that in the view you create a container (derived from CCoeControl), in the container you create the listbox. Put the container onto the control stack and override its OfferKeyEventL and then in there decide what you want to do with the key presses.

    I recommend working through the workbook (http://www.forum.nokia.com/info/sw.n..._Workbook.html)
    and looking at the AVKON resource documents (http://sw.nokia.com/id/0ef53656-8e0d...es_v1_1_en.zip)
    Download Symbian OS now! [url]http://developer.symbian.org[/url]

Similar Threads

  1. HandleListBoxEventL not being called when enter key pressed
    By TorrinLynn in forum Symbian User Interface
    Replies: 17
    Last Post: 2010-08-06, 03:34
  2. MaiscOpenComplete function Not getting called
    By tlgkumar in forum Symbian
    Replies: 4
    Last Post: 2009-01-08, 05:59
  3. canvas lost when dial called in N95
    By sj034166 in forum Symbian
    Replies: 4
    Last Post: 2008-03-06, 13:52
  4. how to remove quick office log file from app manager in nokia n71?
    By imadsharieff in forum General Development Questions
    Replies: 0
    Last Post: 2007-10-31, 15:48
  5. Errors building project in VS.2003
    By jensesaat in forum Symbian
    Replies: 11
    Last Post: 2006-11-13, 16:54

Posting Permissions

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