When you port applications written for S60 3rd Edition to S60 5th Edition, you can continue to use the S60 3rd Edition listbox events intended for keypad interaction. However, it is recommended that you implement support for listbox pointer events. This way you can also distinguish between keypad and touch-screen interactions.
Use the Lists API and the Grids API to implement listboxes and grids. Use the listbox observer to handle touch events.
In S60 3rd Edition, the event EEventEnterKeyPressed
is
sent by the application framework when the user selects the focused item item
in a list or grid. In S60 5th Edition, this same event is simulated when the
user taps a focused item. Therefore, you do not need to make changes to the
lists and grids in your application in order to make them work in touch devices.
If you need to distinguish between keypad and pointer events, add handling
for the event EEventItemDoubleClicked
in your listbox observer.
When you implement support for EEventItemDoubleClicked
,
you also need to add the flag CAknAppUiBase::EAknTouchCompatible
to
your application's CAknAppUiBase::BaseConstructL()
method.
Using this flag results in the framework sending the EEventItemDoubleClicked
event
instead EEventEnterKeyPressed
when a focused list or grid
item is tapped.
Even if you do not need to distinguish between keypad and touch events,
it is recommended that you add handling for the event EEventItemDoubleClicked
in
your listbox observer. In this case, you can handle EEventItemDoubleClicked
and EEventEnterKeyPressed
in
the same way.
To add support for EEventItemDoubleClicked
in a listbox
or grid:
Add the flag EAknTouchCompatible
in
your application UI constructor.
void CCalendarAPIexampleAppUi::ConstructL() { BaseConstructL(EAknTouchCompatible | EAknEnableSkin); ... }
When you
create your listbox or grid component, include information on the class implementing
the MEikListBoxObserver
interface.
void CCalendarAPIexampleSearchContainer::ConstructL(const TRect& aRect) { ... iSearchListBox = new (ELeave) CAknSingleStyleListBox; iSearchListBox->SetContainerWindowL(*this); // MEikListBoxObserver TResourceReader reader; CEikonEnv::Static()->CreateResourceReaderLC(reader, R_CALENDARAPIEXAMPLE_SEARCH_LIST); iSearchListBox->ConstructFromResourceL(reader); CleanupStack::PopAndDestroy(); //reader iSearchListBox->SetListBoxObserver(this); iSearchListBox->CreateScrollBarFrameL(ETrue); iSearchListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); ... }
Add handling of touch events to your listbox observer.
void CCalendarAPIexampleSearchContainer::HandleListBoxEventL( CEikListBox* /*aListBox*/, TListBoxEvent aEventType) { if (aEventType == EEventPenDownOnItem) { //action to take when the stylus is set down on a list item; } else if (aEventType == EEventItemClicked) { //action to take when the stylus is set down on a list item and lifted; } else if (aEventType == EEventItemDoubleClicked) { //action to take when a focused list item is tapped; } else if (aEventType == EEventEnterKeyPressed) { //action to take when the selection key is pressed on the keypad; } else if (aEventType == EEventItemDraggingActioned) { //action to take when a list item is dragged with the stylus; } else { //do something; } }
In order to maintain compatibility with non-touch devices, you are recommended
not to change the interaction model where first the user selects a control
on the device, and then activates it. Use EEventItemDoubleClicked
or EEventEnterKeyPressed
,
sent by the framework when the user taps the list item that has focus, as
the event triggering an action on the item.
An alternative would be direct manipulation using the event EEventItemClicked
so
that the first tap on a list item without focus would trigger an action directly.
This, however, would not work on non-touch devices.