×
Namespaces

Variants
Actions
(Difference between revisions)

Handling new touch-related MEikListBoxObserver events

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Merge KB into wiki)
Line 1: Line 1:
__NOTOC__
+
{{ArticleMetaData <!-- v1.2 -->
__NOEDITSECTION__
+
{{KBCS}}
+
{{ArticleMetaData
+
|id=CS001148
+
|platform=S60 5th Edition
+
|devices=Nokia 5800 XpressMusic
+
|category=Symbian C++
+
|subcategory=Touch UI
+
|creationdate=October 14, 2008
+
|keywords=MEikListBoxObserver::HandleListBoxEventL()
+
 
+
 
|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 control has a listbox and it is listening for listbox events using <tt>MEikListBoxObserver</tt>, you need to handle a few new events related to touch 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 <tt>CAknSingleStyleListBox</tt> already handles its touch UI pointer events in  
+
Note that {{Icode|CAknSingleStyleListBox}} already handles its touch UI pointer events in  
its AVKON base class <tt>CAknColumnListBox::HandlePointerEventL()</tt>. Do not override this implementation.
+
its AVKON base class {{Icode|CAknColumnListBox::HandlePointerEventL()}}. Do not override this implementation.
  
  
Line 55: Line 60:
 
==Source file==
 
==Source file==
  
<tt>CAknSingleStyleListBox</tt> is inside the control and it is created in <tt>ConstructL()</tt>.
+
{{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 <tt>EEventItemDoubleClicked</tt> event related to touch UI. The <tt>EEventEnterKeyPressed</tt> event is the old selection key event (from S60 3rd Edition).
+
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 S60 Platform: Calendar Interim API Example]
+
[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:UI]][[Category:Touch UI]][[Category:Code Snippet]]
+
[[Category:Symbian C++]][[Category:Code Snippet]][[Category:UI]][[Category:Touch UI]][[Category:Code Snippet]]

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

84 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×