S60 mobile devices are not actually pointer devices. 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 does some processing
for the event. 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.
Note that, 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; } } }