Suppressing unwanted pointer events
Article Metadata
| ID | Creation date | November 9, 2008 | |
| Platform | S60 5th Edition | Tested on devices | |
| Category | Symbian C++ | Subcategory |
| Keywords (APIs, classes, methods, functions): Touch UI Utilities API, CAknPointerEventSuppressor, SuppressPointerEvent() |
Contents |
Overview
Enabling support of touch UI brought, apart of the new possibilities, additional problems to be solved. One of them is suppressing unwanted pointer events. And the typical case of such events filtering is enabling 'finger-friendly' mode in an application. Using fingers instead of stylus supposes less accurate tapping, dragging. For example activating of rather small area on the screen with fingers could lead to unwanted drag events as area of finger touch could vary at run-time.
To help in solving such situations S60 5th Edition SDK provides CAknPointerEventSuppressor class, which is a part of Touch UI Utilities API. The core method of this class is SuppressPointerEvent(const TPointerEvent &aPointerEvent) - for testing whether the specified pointer event should be ignored. And to set options of suppressing pointer events three methods are implemented: SetMaxTapDuration(TTimeIntervalMicroSeconds aDuration), SetMaxTapMove (TSize aMoveLimits), SetMinInterDragInterval(TTimeIntervalMicroSeconds aInterval).
MMP file
LIBRARY avkon.lib
CAPABILITY could be self-signed
Header file
#include <aknpointereventsuppressor.h>
class CSampleControl: ...
{
...
public:
void ConstructL();
...
private:
CAknPointerEventSuppressor* iSuppressor;
TBool iTap; // Boolean flag to indicate whether tap event occured
...
};
Source file
...
void CSampleControl::ConstructL()
{
...
iSuppressor = CAknPointerEventSuppressor::NewL();
// Tuning up rather small control to enable 'finger-friendly' mode
// Set max tap duration interval to 0.3 sec
iSupressor->SetMaxTapDuration(300000);
// Set max tap move as half of control size
TSize controlSize = Size();
iSuppressor->SetMaxTapMove(TSize(controlSize.iWidth/2, controlSize.iHeight/2));
// Set minimum interval between drag events to 0.2 sec
iSuppressor->SetMinInterDragInterval(200000);
...
}
...
void CSampleControl::HandlePointerEventL(const TPointerEvent& aPointerEvent)
{
// Check whether pointer event meets established earlier criteries
if (iSuppressor->SuppressPointerEvent(aPointerEvent))
return;
// Distinguish tap events from drag events
switch (aPointerEvent.iType)
{
case TPointerEvent::EButton1Down:
iTap = ETrue; // Set flag to ETrue
break;
case TPointerEvent::EButton1Up:
if (iTap)
DoTapEventHandling();
break;
case TPointerEvent::EDrag:
iTap = EFalse; // Reset flag to EFalse,
// just because the following EButton1Up event should
// should not be handled as tap event
DoDragEventHandling();
break;
default:
break;
}
}
Postconditions
Unwanted pointer events have been suppressed.
See also
Handling pointer events in Symbian C++
Enabling drag events in Symbian C++ on touch-enabled devices


(no comments yet)