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. Thanks for all your past and future contributions.

How to Enable/Disable Drag and Move Events in a Control

From Wiki
Jump to: navigation, search

This snippet shows how to Enable or Disable Drag and Move Pointer events in a Symbian C++ UI Control.

Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic.
Platform(s): S60 5th Edition
S60 5th Edition
Platform Security
Signing Required: Self-Signed
Capabilities: None
Keywords: Pointer Event,Drag Event, Move Event, HandlePointerEventL().
Created: vasant21 (30 Nov 2008)
Last edited: hamishwillee (18 Sep 2012)



By default, pointer drag events and pointer move events are not delivered to controls. The default behaviour when a window is created is that move, drag, enter and exit events are filtered out and not delivered to the client. In order for the control to receive drag events occurring in its window, we need to call EnableDragEvents() in the control’s construction routine. Having done that, the control will receive drag events as calls to its HandlePointerEventL() virtual function.


Here we assume that we already have a working code for UI based Application.

MMP file

The following capabilities and libraries are required:

LIBRARY cone.lib 
include <COECNTRL.H>

Enabling Drag and Move Events

void CSomeAppView::ConstructL(const TRect& aRect)
// Create a window for the container
. .
. . .
// Enable Drag Events.
// OR can also be done with
Window().PointerFilter(EPointerFilterDrag, 0);
.. ..

Handling Drag and Move Events

Control receive's drag and move events in its HandlePointerEventL() virtual function, hence whatever processing is required for Drag and Move events can be done inside this function.

void CSomeAppView::HandlePointerEventL(const TPointerEvent& aPointerEvent)
switch (aPointerEvent.iType)
. .
. . .
case TPointerEvent::EDrag:
// Handle drag event here.
case TPointerEvent::EMove:
// Handle move event here.
// do something

Disabling Drag and Move Events

The control framework does not provide a function to disable drag events at a later time, but this can be done via the Window Server API, by calling Window()->PointerFilter().

// A 1 bit causes the corresponding event to be filtered out, a 0 bit lets through the corresponding event. 
Window().PointerFilter(EPointerFilterDrag, 1);


Drag and Move Pointer Events will be Enabled/Disabled.

This page was last modified on 18 September 2012, at 06:15.
25 page views in the last 30 days.