Archived:Applying actions on list box items using Symbian C++
hamishwillee
(Talk | contribs) m (Bot change of links to internal format.) |
hamishwillee
(Talk | contribs) m (Hamishwillee - Bot change of template (Template:KnowledgeBase) - now using Template:ArticleMetaData) |
||
| Line 5: | Line 5: | ||
[[Category:Technical Solution]] | [[Category:Technical Solution]] | ||
| − | {{ | + | {{ArticleMetaData |
|id=TSS000647 | |id=TSS000647 | ||
|platform=S60 1st Edition<br>S60 2nd Edition and FP1, FP2, FP3<br>S60 3rd Edition and FP1 | |platform=S60 1st Edition<br>S60 2nd Edition and FP1, FP2, FP3<br>S60 3rd Edition and FP1 | ||
| Line 13: | Line 13: | ||
|creationdate=May 10, 2007 | |creationdate=May 10, 2007 | ||
|keywords= | |keywords= | ||
| + | |||
| + | |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]]) --> | ||
| + | |sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) --> | ||
| + | |devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) --> | ||
| + | |signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer --> | ||
| + | |capabilities=<!-- Capabilities required (e.g. Location, NetworkServices.) --> | ||
| + | |author=[[User:Technical writer 2]] | ||
}} | }} | ||
Revision as of 14:14, 25 June 2011
Article Metadata
Compatibility
S60 2nd Edition and FP1, FP2, FP3
S60 3rd Edition and FP1
Article
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:
[[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.

