Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Revision as of 04:38, 30 May 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How to Handle Pointer Events in a Custom Control

From Wiki
Jump to: navigation, search

Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic.
Platform(s): S60 5th Edition
S60 5th Edition
Platform Security
Signing Required: Self-Signed
Capabilities: None
Keywords: HandlePointerEventL(),Custom Control.
Created: vasant21 (26 Oct 2008)
Last edited: hamishwillee (30 May 2013)



This snippet shows how to handle pointer events in a custom control and route them to a proper component control by validating the pointer area against the control rect.

This snippet can be self-signed.


Here we assume that we already have a working code for custom control, and we also assume that we have two components: iEdwin1 and iEdwin2 in a custom control.

MMP file

The following capabilities and libraries are required:

LIBRARY cone.lib

#include <COECNTRL.H> 
void CCustomContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent)
// Validate pointer position.
if( iEdwin1->Rect().Contains( aPointerEvent.iPosition ) )
// click on edwin1 pass the pointer event. //
iEdwin1->HandlePointerEventL( aPointerEvent );
else if( iEdwin2->Rect().Contains( aPointerEvent.iPosition ) )
// click on edwin2 pass the pointer event. //
iEdwin2->HandlePointerEventL( aPointerEvent );
// simply calling the base class implementation //


Pointer position will validated against the control rectangle and the pointer events will be routed to appropriate control.

This page was last modified on 30 May 2013, at 04:38.
58 page views in the last 30 days.