×
Namespaces

Variants
Actions
(Difference between revisions)

Handling new touch-related MEikListBoxObserver events

From Nokia Developer Wiki
Jump to: navigation, search
tepaa (Talk | contribs)
tepaa (Talk | contribs)
Line 69: Line 69:
 
     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 78:
 
     // 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 105: Line 106:
 
==Postconditions==
 
==Postconditions==
  
Application handles  
+
Application handles listbox pointer events.
  
 
==See also==
 
==See also==

Revision as of 21:55, 9 October 2008


ID   Creation date September 30, 2008
Platform S60 5th Edition Tested on devices Nokia 5800 XpressMusic
Category Symbian C++ Subcategory Touch UI


Keywords (APIs, classes, methods, functions): MEikListBoxObserver::HandleListBoxEventL()

Overview

S60 5th Edition supports touch events. All AVKON ui controls handles touch ui events and you do not need to implement nothing new.

If your ui control has the listbox and it's listening listbox events by MEikListBoxObserver you have to handle few new touch ui related events:

* 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 handles already its touch ui poiter 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

We have CAknSingleStyleListBox inside our control and it's 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();
}

Here is listbox event listening, see new EEventItemDoubleClicked touch ui related event. EEventEnterKeyPressed event is 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

Application handles listbox pointer events.

See also

[S60 5th Calendar Example]

119 page views in the last 30 days.
×