You Are Here:

Community: Wiki

This page was last modified on 4 November 2008, at 14:08.

TSS000647 - Applying actions on list box items

From Forum Nokia Wiki


ID TSS000647 Creation date May 10, 2007
Platform S60 1st Edition
S60 2nd Edition and FP1, FP2, FP3
S60 3rd Edition and FP1
Devices
Category Symbian C++ Subcategory UI, UI components


Keywords (APIs, classes, methods, functions):

Overview

Applying actions on list box items

Description

Below is a code snippet demonstrating how to apply actions on a list box item selected by the user.
The code to create a simple list box can be obtained from the link below:
http://wiki.forum.nokia.com/index.php/How_to_create_a_simple_listbox
It is possible to apply any actions (e.g., displaying a popup or a dialog) by catching key events for a list box that currently has keyboard focus. This is done in the OfferKeyEventL() function of the container class that owns the list box.

Solution

    TKeyResponse CMyExampleAppView::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
        {
        if(aType != EEventKey)
            {
            return EKeyWasNotConsumed;
            }
        switch(aKeyEvent.iCode)
            {
            case EKeyUpArrow:
            case EKeyDownArrow:
                {
                // Forward up and down key press events to the list box
                return iListBox->OfferKeyEventL( aKeyEvent, aType );
                }
            case EKeyOK: // display an information note when item is selected
                {
                _LIT(KFormatMessage, "Selected item: %d");
                TInt idx = iListBox->CurrentItemIndex();
                TBuf<32> message;
                message.Format(KFormatMessage, idx);
                CAknInformationNote* Note = new (ELeave) CAknInformationNote;
                Note->ExecuteLD(message);
                return EKeyWasConsumed;
                }
            default:
                break;
            }
       
        return EKeyWasNotConsumed;
        }
Also make sure to add this line
    AddToStackL( iAppView );
in AppUi’s ConstructL() to add the view/container to the control stack and receive OfferKeyEventL() calls.

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia