Namespaces

Variants
Actions

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 over the next few weeks. Thanks for all your past and future contributions.

Enabling drag events in Symbian C++ on touch-enabled devices

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.

Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 5th Edition
Article
Keywords: CCoeControl::EnableDragEvents()
Created: tepaa (03 Oct 2008)
Last edited: lpvalente (23 Sep 2014)

Contents

Overview

S60 5th Edition supports touch events. All AVKON UI controls handle touch UI events and you do not need to implement anything new.

If you want to listen for drag events in your custom CCoeControl UI control, use CCoeControl::EnableDragEvents().


MMP file

The following libraries are required:

LIBRARY cone.lib

Header file

private:
void ConstructL(const TRect& aRect);
void HandlePointerEventL(const TPointerEvent& aPointerEvent);
void Move(const TPoint& aPoint);
 
private:
TPoint iMovePoint;


Source file

Enable drag event listening in the container control ConstructL().

EnableDragEvents() needs to be called only once in the entire application.
void CMyControl::ConstructL(const TRect& /*aRect*/)
{
// Create window of this container control
CreateWindowL();
 
// Enable drag events listening
EnableDragEvents();
 
// ...

Drag events are received.

void CMyControl::HandlePointerEventL(const TPointerEvent& aPointerEvent)
{
if (aPointerEvent.iType == TPointerEvent::EButton1Down)
{
iMovePoint = aPointerEvent.iPosition;
}
else if (aPointerEvent.iType == TPointerEvent::EDrag)
{
// Drag events received, what to do with it?
 
// We could move this control...
Move(aPointerEvent.iPosition);
 
// Store current point
iMovePoint = aPointerEvent.iPosition;
 
// Draw this control again because we move to position of it
DrawNow();
}
 
// ...

Moving control to dragging point:

void CMyControl::Move(const TPoint& aPoint)
{
TPoint offset;
 
// Calculate moving offset
offset.iX = aPoint.iX - iMovePoint.iX;
offset.iY = aPoint.iY - iMovePoint.iY;
 
TRect rect = Rect();
 
// Move this control
rect.Move(offset);
}


Postconditions

Drag events are received and control is moved to the pointer location.


See also

S60 5th Edition: Solitaire Game Example

S60 Platform: Image Converter Example

Handling pointer events in Symbian C++

CS001145 - Pointer capturing in touch-enabled devices

This page was last modified on 23 September 2014, at 19:57.
102 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×