Detecting long tap using CAknLongTapDetector
Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 5th Edition
Article
Keywords: CAknLongTapDetector, MAknLongTapDetectorCallBack
Created: tepaa
(14 Oct 2008)
Last edited: pooja_1650
(20 Jun 2012)
Contents |
Overview
CAknLongTapDetector receives pointer events from the owner application or owner control and returns the location if a long tap event occurs.
After a short period of time (the default is 0.15 seconds), an animation is displayed on the screen next to the stylus to inform the user of the long tap functionality. The animation can be turned OFF by the application if desired.
This snippet can be self-signed.
MMP file
The following capabilities and libraries are required:
CAPABILITY None
LIBRARY avkon.lib
Header file
Your UI control should implement the MAknLongTapDetectorCallBack interface.
#include <aknlongtapdetector.h>
class CImageConverterContainer : public CCoeControl,
public MCoeControlObserver, public MAknLongTapDetectorCallBack
{
...
private: // From MAknLongTapDetectorCallBack
void HandleLongTapEventL( const TPoint& aPenEventLocation,
const TPoint& aPenEventScreenLocation );
private:
CAknLongTapDetector* iLongTapDetector;
...
}
Source file
// Create long tap detector
void CImageConverterContainer::ConstructL(const TRect& /*aRect*/)
{
...
iLongTapDetector = CAknLongTapDetector::NewL(this);
...
}
// Redirect pointer events to long tap detector
void CImageConverterContainer::HandlePointerEventL(const TPointerEvent&
aPointerEvent)
{
iLongTapDetector->PointerEventL(aPointerEvent);
...
}
// This method is called when long tap occurs
void CImageConverterContainer::HandleLongTapEventL( const TPoint&
aPenEventLocation, const TPoint& aPenEventScreenLocation )
{
// TODO: What to do when long tap detected
...
}
Postconditions
Long taps can be detected in the application.


(no comments yet)