Namespaces
Variants
Actions
(Difference between revisions)

Handling new touch-related MEikListBoxObserver events

Jump to: navigation, search
 
(11 intermediate revisions by 5 users not shown)
Line 1: Line 1:
__NOTOC__
+
{{ArticleMetaData <!-- v1.2 -->
__NOEDITSECTION__
+
|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]]) -->
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
|devices= Nokia 5800 XpressMusic
|-
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|'''ID''' || &nbsp;
+
|platform= S60 5th Edition
|'''Creation date''' || September 30, 2008
+
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
|-
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
|'''Platform''' || S60 5th Edition
+
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
|'''Tested on devices'''  || Nokia 5800 XpressMusic
+
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
|-
+
|keywords= MEikListBoxObserver::HandleListBoxEventL()
|'''Category''' || Symbian C++
+
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
|'''Subcategory''' || Touch UI
+
|translated-by= <!-- [[User:XXXX]] -->
|}
+
|translated-from-title= <!-- Title only -->
 
+
|translated-from-id= <!-- Id of translated revision -->
 
+
|review-by= <!-- After re-review: [[User:username]] -->
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
|review-timestamp= <!-- After re-review: YYYYMMDD -->
|-
+
|update-by= <!-- After significant update: [[User:username]]-->
|'''Keywords (APIs, classes, methods, functions):''' MEikListBoxObserver::HandleListBoxEventL()
+
|update-timestamp= <!-- After significant update: YYYYMMDD -->
|}
+
|creationdate= 20081003
 +
|author= [[User:Tepaa]]
 +
<!-- The following are not in current metadata -->
 +
|subcategory= Touch UI
 +
|id= CS001148
 +
}}
  
 
==Overview==
 
==Overview==
  
S60 5th Edition supports touch events. All AVKON ui controls handles touch ui events and
+
S60 5th Edition supports touch events. All AVKON UI controls handle touch UI events and
you do not need to implement nothing new.
+
you do not need to implement anything new.
  
If your ui control has the listbox and it's listening listbox events by MEikListBoxObserver you  
+
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:
have to handle few new touch ui related events:
+
 
  * EEventItemClicked            // Item single-tap event
 
  * EEventItemClicked            // Item single-tap event
 
  * EEventItemDoubleClicked      // Item two-taps event
 
  * EEventItemDoubleClicked      // Item two-taps event
Line 32: Line 36:
 
  * EEventItemDraggingActioned  // Pen is dragged from item to another
 
  * EEventItemDraggingActioned  // Pen is dragged from item to another
  
Note that CAknSingleStyleListBox handles already its touch ui poiter events in  
+
Note that {{Icode|CAknSingleStyleListBox}} already handles its touch UI pointer events in  
its AVKON base class CAknColumnListBox::HandlePointerEventL(). Do not override this implementation.
+
its AVKON base class {{Icode|CAknColumnListBox::HandlePointerEventL()}}. Do not override this implementation.
  
  
Line 56: Line 60:
 
==Source file==
 
==Source file==
  
We have CAknSingleStyleListBox inside our control and it's created in ConstructL()
+
{{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 69: Line 73:
 
     iSearchListBox->SetContainerWindowL(*this);  
 
     iSearchListBox->SetContainerWindowL(*this);  
 
     TResourceReader reader;  
 
     TResourceReader reader;  
     CEikonEnv::Static()->CreateResourceReaderLC(reader, R_XXXX);  
+
     CEikonEnv::Static()->CreateResourceReaderLC(reader, R_MY_LISTBOX);  
 
     iSearchListBox->ConstructFromResourceL(reader);  
 
     iSearchListBox->ConstructFromResourceL(reader);  
 
     CleanupStack::PopAndDestroy(); //reader
 
     CleanupStack::PopAndDestroy(); //reader
Line 78: Line 82:
 
     // Enable scrollbars
 
     // Enable scrollbars
 
     iSearchListBox->CreateScrollBarFrameL(ETrue);
 
     iSearchListBox->CreateScrollBarFrameL(ETrue);
     iSearchListBox->ScrollBarFrame()->SetScrollBarVisibilityL(  CEikScrollBarFrame::EOff,
+
     iSearchListBox->ScrollBarFrame()
                                                                CEikScrollBarFrame::EAuto);
+
    ->SetScrollBarVisibilityL(  CEikScrollBarFrame::EOff,
 +
    CEikScrollBarFrame::EAuto);
 
      
 
      
 
     Components().AppendLC(iSearchListBox,1);
 
     Components().AppendLC(iSearchListBox,1);
Line 89: Line 94:
 
</code>
 
</code>
  
Here is listbox event listening, see new EEventItemDoubleClicked touch ui related event.  
+
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).
EEventEnterKeyPressed event is 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 105: Line 109:
 
==Postconditions==
 
==Postconditions==
  
Application handles  
+
The application handles listbox pointer events.
  
 
==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 S60 Platform: Calendar Interim API Example]
  
  
[[Category:Symbian C++]][[Category:Code Examples]][[Category:Touch UI]]
+
[[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
Devices(s): Nokia 5800 XpressMusic

Compatibility
Platform(s): S60 5th Edition

Article
Keywords: MEikListBoxObserver::HandleListBoxEventL()
Created: tepaa (03 Oct 2008)
Last edited: hamishwillee (14 Jun 2012)

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.

See also

S60 Platform: Calendar Interim API Example

This page was last modified on 14 June 2012, at 05:11.
140 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