×
Namespaces

Variants
Actions
(Difference between revisions)

Handling new touch-related MEikListBoxObserver events

From Nokia Developer Wiki
Jump to: navigation, search
jaaura (Talk | contribs)
m
hamishwillee (Talk | contribs)
 
(5 intermediate revisions by 2 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]]) -->
{{KBCS}}
+
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
{{CodeSnippet
+
|devices= Nokia 5800 XpressMusic
|id=CS001148
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|platform=S60 5th Edition
+
|platform= S60 5th Edition
|devices=Nokia 5800 XpressMusic
+
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
|category=Symbian C++
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
|subcategory=Touch UI
+
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
|creationdate=October 14, 2008
+
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
|keywords=MEikListBoxObserver::HandleListBoxEventL()
+
|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 17: 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 23: 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 47: 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 81: 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 99: Line 112:
  
 
==See also==
 
==See also==
[http://www.forum.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: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

[edit] 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.


[edit] MMP file

The following libraries are required:

LIBRARY avkon.lib
LIBRARY eikcoctl.lib
LIBRARY eikctl.lib

[edit] Header file

#include <aknlists.h> // CAknSingleStyleListBox
#include <eiklbo.h> // MEikListBoxObserver


[edit] 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...
}
}


[edit] Postconditions

The application handles listbox pointer events.

[edit] See also

S60 Platform: Calendar Interim API Example

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

×