Detecting long tap using CAknLongTapDetector

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Platform(s): S60 5th Edition
Keywords: CAknLongTapDetector, MAknLongTapDetectorCallBack
Created: tepaa (14 Oct 2008)
Last edited: pooja_1650 (20 Jun 2012)



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 );
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&
// 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


Long taps can be detected in the application.

See also

S60 Platform: Image Converter Example

This page was last modified on 20 June 2012, at 09:54.
48 page views in the last 30 days.