Handling new touch-related MEikListBoxObserver events
hamishwillee
(Talk | contribs) m (Hamishwillee - Bot change of template (Template:CodeSnippet) - now using Template:ArticleMetaData) |
hamishwillee
(Talk | contribs) m (moved CS001148 - Handling new touch-related MEikListBoxObserver events to Handling new touch-related MEikListBoxObserver events) |
||
| (2 intermediate revisions by one user not shown) | |||
| Line 1: | Line 1: | ||
| − | + | {{ArticleMetaData <!-- v1.2 --> | |
| − | + | ||
| − | + | ||
| − | {{ArticleMetaData | + | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
|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]]) --> | ||
| − | |sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) --> | + | |devices= Nokia 5800 XpressMusic |
| − | |devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) --> | + | |sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) --> |
| − | |signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer --> | + | |platform= S60 5th Edition |
| − | |capabilities=<!-- Capabilities required (e.g. Location, NetworkServices. -->) | + | |devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) --> |
| − | |author=[[User:Tepaa]] | + | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> |
| + | |signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer --> | ||
| + | |capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> | ||
| + | |keywords= MEikListBoxObserver::HandleListBoxEventL() | ||
| + | |language= <!-- Language category code for non-English topics - e.g. Lang-Chinese --> | ||
| + | |translated-by= <!-- [[User:XXXX]] --> | ||
| + | |translated-from-title= <!-- Title only --> | ||
| + | |translated-from-id= <!-- Id of translated revision --> | ||
| + | |review-by= <!-- After re-review: [[User:username]] --> | ||
| + | |review-timestamp= <!-- After re-review: YYYYMMDD --> | ||
| + | |update-by= <!-- After significant update: [[User:username]]--> | ||
| + | |update-timestamp= <!-- After significant update: YYYYMMDD --> | ||
| + | |creationdate= 20081003 | ||
| + | |author= [[User:Tepaa]] | ||
| + | <!-- The following are not in current metadata --> | ||
| + | |subcategory= Touch UI | ||
| + | |id= CS001148 | ||
}} | }} | ||
| Line 25: | Line 30: | ||
you do not need to implement anything new. | you do not need to implement anything new. | ||
| − | If your UI | + | If your UI control has a listbox and it is listening for listbox events using {{Icode|MEikListBoxObserver}}, you need to handle a few new events related to touch UI: |
* EEventItemClicked // Item single-tap event | * EEventItemClicked // Item single-tap event | ||
* EEventItemDoubleClicked // Item two-taps event | * EEventItemDoubleClicked // Item two-taps event | ||
| Line 31: | Line 36: | ||
* EEventItemDraggingActioned // Pen is dragged from item to another | * EEventItemDraggingActioned // Pen is dragged from item to another | ||
| − | Note that | + | Note that {{Icode|CAknSingleStyleListBox}} already handles its touch UI pointer events in |
| − | its AVKON base class | + | its AVKON base class {{Icode|CAknColumnListBox::HandlePointerEventL()}}. Do not override this implementation. |
| Line 55: | Line 60: | ||
==Source file== | ==Source file== | ||
| − | + | {{Icode|CAknSingleStyleListBox}} is inside the control and it is created in {{Icode|ConstructL()}}. | |
<code cpp> | <code cpp> | ||
void CMyContainer::ConstructL(const TRect& aRect) | void CMyContainer::ConstructL(const TRect& aRect) | ||
| Line 89: | Line 94: | ||
</code> | </code> | ||
| − | Listbox event listening is implemented below. Note the new | + | Listbox event listening is implemented below. Note the new {{Icode|EEventItemDoubleClicked}} event related to touch UI. The {{Icode|EEventEnterKeyPressed}} event is the old selection key event (from S60 3rd Edition). |
<code cpp> | <code cpp> | ||
void CMyContainer::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType) | void CMyContainer::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType) | ||
| Line 107: | Line 112: | ||
==See also== | ==See also== | ||
| − | [http://www.developer.nokia.com/info/sw.nokia.com/id/a856c0b7-2b71-480e-810e-99acedb24b77/S60_Platform_Calendar_Interim_API_Example.html | + | [http://www.developer.nokia.com/info/sw.nokia.com/id/a856c0b7-2b71-480e-810e-99acedb24b77/S60_Platform_Calendar_Interim_API_Example.html S60 Platform: Calendar Interim API Example] |
| − | [[Category:Symbian C++]][[Category:Code | + | [[Category:Symbian C++]][[Category:Code Snippet]][[Category:UI]][[Category:Touch UI]][[Category:Code Snippet]] |
Latest revision as of 05:11, 14 June 2012
Article Metadata
Tested with
Compatibility
Article
Contents |
Overview
S60 5th Edition supports touch events. All AVKON UI controls handle touch UI events and you do not need to implement anything new.
If your UI control has a listbox and it is listening for listbox events using MEikListBoxObserver, you need to handle a few new events related to touch UI:
* EEventItemClicked // Item single-tap event * EEventItemDoubleClicked // Item two-taps event * EEventPenDownOnItem // Pen is down and over an item * EEventItemDraggingActioned // Pen is dragged from item to another
Note that CAknSingleStyleListBox already handles its touch UI pointer events in its AVKON base class CAknColumnListBox::HandlePointerEventL(). Do not override this implementation.
MMP file
The following libraries are required:
LIBRARY avkon.lib
LIBRARY eikcoctl.lib
LIBRARY eikctl.lib
Header file
#include <aknlists.h> // CAknSingleStyleListBox
#include <eiklbo.h> // MEikListBoxObserver
Source file
CAknSingleStyleListBox is inside the control and it is created in ConstructL().
void CMyContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
// Initialize component array
InitComponentArrayL();
// Create listbox
iSearchListBox = new (ELeave) CAknSingleStyleListBox;
iSearchListBox->SetContainerWindowL(*this);
TResourceReader reader;
CEikonEnv::Static()->CreateResourceReaderLC(reader, R_MY_LISTBOX);
iSearchListBox->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy(); //reader
// --> Start event listening
iSearchListBox->SetListBoxObserver(this);
// Enable scrollbars
iSearchListBox->CreateScrollBarFrameL(ETrue);
iSearchListBox->ScrollBarFrame()
->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
CEikScrollBarFrame::EAuto);
Components().AppendLC(iSearchListBox,1);
CleanupStack::Pop( iSearchListBox );
SetRect(aRect);
ActivateL();
}
Listbox event listening is implemented below. Note the new EEventItemDoubleClicked event related to touch UI. The EEventEnterKeyPressed event is the old selection key event (from S60 3rd Edition).
void CMyContainer::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
{
if (aEventType == EEventEnterKeyPressed || aEventType == EEventItemDoubleClicked)
{
// TODO: Listbox got double click, what to do?
// From CEikListBox::CurrentItemIndex() you could get the selected row...
}
}
Postconditions
The application handles listbox pointer events.

