The Symbian platform provides additional touch events to enable drag events and to specify screen areas for touch events.
By default, the Symbian platform sends only EButton1Up
and EButton1Down
touch events to applications.
If you want to enable EDrag
touch events,
implement CCoeControl::EnableDragEvents()
in your
container class.
When the mobile device user drags the stylus on the screen, TPointerEvent::EDrag()
events are sent. When dragging stops,
the application receives the event TPointerEvent::EButton1Up()
.
void CTableauControl::ConstructL( const TRect& aRect ) { // This is parent window CreateWindowL(); EnableDragEvents(); SetRect( aRect ); SetExtentToWholeScreen(); // Initialize component array InitComponentArrayL(); //Implement your own logic here ActivateL(); }
It is enough that the container control set EnableDragEvents()
in its construction. EnableDragEvents()
need not
be set again for the child controls to receive dragging events.
Particularly when you
are receiving drag events it may be that an object in the window may
be drawn by one control, while the pointer is over another control.
In cases where you want to ensure that pointer events are received
by the intended control, implement CCoeControl::SetPointerCapture()
.
When a control receives a TPointerEvent::EButton1Down()
event, all events will be sent to this control until the next TPointerEvent::EButton1Up()
event. If you want to have
events to be sent to another control before theTPointerEvent::EButton1Up()
event, call SetPointerCapture(ETrue)
from the new
control.
When the new control has received its pointer event
and TPointerEvent::EButton1Up()
has been received,
you have to call SetPointerCapture(EFalse)
from the
new control to stop events being sent to it indefinitely.
To specify screen areas (TRect
) for touch events, see the example below.
void CTableauControl::HandlePointerEventL(const TPointerEvent& aPointerEvent) { // Does the user point exit text on screen? // iExitRect is rectangle of the text area on screen. if (iExitRect.Contains(aPointerEvent.iPosition)) { if (iEikonEnv->QueryWinL(_L("Klondike"),_L("Exit?"))) { // Exit was pointed, then do exit (static_cast<CKlondikeAppUi*>(iEikonEnv->AppUi()))->HandleCommandL(EEikCmdExit); return; } } ... }
In cases where
you want to make sure your control receives only touch EButton1Up
events after receiving a touch EButton1Down
event, implement CCoeControl::IgnoreEventsUntilNextPointerUp()
.