Namespaces
Variants
Actions
(Difference between revisions)

Archived:Applying actions on list box items using Symbian C++

Jump to: navigation, search
m (Hamishwillee - Update code block to use correct block markup)
m (Hamishwillee - Fix typos)
Line 1: Line 1:
 
[[Category:Technical Solution]][[Category:Symbian C++]][[Category:UI]][[Category:S60 1st Edition]][[Category:S60 2nd Edition]][[Category:S60 3rd Edition]][[Category:S60 3rd Edition, Feature Pack 1]]
 
[[Category:Technical Solution]][[Category:Symbian C++]][[Category:UI]][[Category:S60 1st Edition]][[Category:S60 2nd Edition]][[Category:S60 3rd Edition]][[Category:S60 3rd Edition, Feature Pack 1]]
 
{{KBTS}}
 
{{KBTS}}
__NOTOC__
+
__NOTOC__ __NOEDITSECTION__
__NOEDITSECTION__
+
 
+
 
+
 
+
 
{{ArticleMetaData
 
{{ArticleMetaData
 
|id=TSS000647
 
|id=TSS000647
Line 12: Line 8:
 
|creationdate=20070510
 
|creationdate=20070510
 
|keywords=
 
|keywords=
 
 
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
Line 26: Line 21:
  
 
== Description ==
 
== Description ==
Below is a code snippet demonstrating how to apply actions on a list box item selected by the user.<br>The code to create a simple list box can be obtained from the link below:<br>[[How to create a simple listbox<br>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.
+
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: [[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 ==
 
== Solution ==

Revision as of 08:50, 21 December 2011

Template:KBTS

Article Metadata

Compatibility
Platform(s): S60 1st Edition
S60 2nd Edition and FP1, FP2, FP3
S60 3rd Edition and FP1

Article
Created: User:Technical writer 2 (10 May 2007)
Last edited: hamishwillee (21 Dec 2011)

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: 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.

322 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved