How to Handle Pointer Events in a Custom Control
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.
The following capabilities and libraries are required:
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.