Namespaces
Variants
Actions
(Difference between revisions)

Handling new touch-related MEikListBoxObserver events

Jump to: navigation, search
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
__NOEDITSECTION__
 
__NOEDITSECTION__
 
+
{{KBCS}}
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
{{CodeSnippet
|-
+
|id=CS001148
|'''ID''' ||  
+
|platform=S60 5th Edition
|'''Creation date''' || September 30, 2008
+
|devices=Nokia 5800 XpressMusic
|-
+
|category=Symbian C++
|'''Platform''' || S60 5th Edition
+
|subcategory=Touch UI
|'''Tested on devices'''  || Nokia 5800 XpressMusic
+
|creationdate=October 14, 2008
|-
+
|keywords=MEikListBoxObserver::HandleListBoxEventL()
|'''Category''' || Symbian C++
+
}}
|'''Subcategory''' || Touch UI
+
|}
+
 
+
 
+
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
|-
+
|'''Keywords (APIs, classes, methods, functions):''' MEikListBoxObserver::HandleListBoxEventL()
+
|}
+
  
 
==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 <tt>MEikListBoxObserver</tt>, 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 23:
 
  * 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 <tt>CAknSingleStyleListBox</tt> already handles its touch UI pointer events in  
its AVKON base class CAknColumnListBox::HandlePointerEventL(). Do not override this implementation.
+
its AVKON base class <tt>CAknColumnListBox::HandlePointerEventL()</tt>. Do not override this implementation.
  
  
Line 56: Line 47:
 
==Source file==
 
==Source file==
  
We have CAknSingleStyleListBox inside our control and it's created in ConstructL()
+
<tt>CAknSingleStyleListBox</tt> is inside the control and it is created in <tt>ConstructL()</tt>.
 
<code cpp>
 
<code cpp>
 
void CMyContainer::ConstructL(const TRect& aRect)
 
void CMyContainer::ConstructL(const TRect& aRect)
Line 90: Line 81:
 
</code>
 
</code>
  
Here is listbox event listening, see new EEventItemDoubleClicked touch ui related event.  
+
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).
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 106: Line 96:
 
==Postconditions==
 
==Postconditions==
  
Application handles listbox pointer events.
+
The application handles listbox pointer events.
  
 
==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 5th Calendar Example]]
+
[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]
  
  
 
[[Category:Symbian C++]][[Category:Code Examples]][[Category:Touch UI]]
 
[[Category:Symbian C++]][[Category:Code Examples]][[Category:Touch UI]]

Revision as of 13:32, 14 October 2008


Template:KBCS

Article Metadata

Tested with
Devices(s): Nokia 5800 XpressMusic

Compatibility
Platform(s): S60 5th Edition

Article
Keywords: MEikListBoxObserver::HandleListBoxEventL()
Created: (14 Oct 2008)
Last edited: Forum Nokia KB (14 Oct 2008)

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

124 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