Pointer events are handled by the controls. A control should implement the function CCoeControl:HandlePointerEventL() to be able to handle pointer events. The CCoeControl:HandlePointerEventL() function is called by the framework whenever a pointer event occurs within the control.
virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
Before passing pointer events to controls, the framework performs the event processing. If a TPointerEvent::EButton1Down() event occurred in the control and the control does not currently have keyboard focus, it sends an event of type MCoeControlObserver::EEventRequestFocus() to the control's observer — normally the control's container. The container control should then set focus onto the control in which the TPointerEvent::EButton1Down() event occurred.
By default, pointer drag events and pointer move events are not delivered to controls. For additional information, see functions RWindowBase::PointerFilter() and CCoeControl::ClaimPointerGrab().
The following code example demonstrates usage of the TPointerEvent class:
void CEventsAppView::HandlePointerEventL( const TPointerEvent& aPointerEvent ) { switch( aPointerEvent.iType ) { case TPointerEvent::EButton1Down: { // Button 1 down // Get pointer position TPoint positionX = aPointerEvent.iPosition.iX; TPoint positionY = aPointerEvent.iPosition.iY; break; } case TPointerEvent::EButton1Up: { // button 1 up break; } case TPointerEvent::EDrag: { // drag event break; } case TPointerEvent::EMove: { // move event break; } default: { // do something break; } } }
For information on advanced pointer events, see Advanced pointers section.