enable.tools.drag_tool module

Defines the base DragTool class.

class enable.tools.drag_tool.DragTool(component=None, **traits)[source]

Bases: enable.base_tool.BaseTool

Base class for tools that are activated by a drag operation.

This tool insulates the drag operation from double clicks and the like, and gracefully manages the transition into and out of drag mode.


Called when the drag is cancelled.

A drag is usually cancelled by receiving a mouse_leave event when end_drag_on_leave is True, or on_drag_leave is ‘cancel’, or by the user pressing any of the cancel_keys.


Called when a mouse event causes the drag operation to end.

A drag is ended when a user releases the mouse, or by receiving a mouse_leave event when on_drag_leave is ‘end’.


Called when the drag operation starts.

The event parameter is the mouse event that established the drag operation; its x and y attributes correspond to the current location of the mouse, and not to the position of the mouse when the initial left_down or right_down event happened.


This method is called for every mouse_move event that the tool receives while the user is dragging the mouse.

It is recommended that subclasses do most of their work in this method.

is_draggable(x, y)[source]

Returns whether the (x,y) position is in a region that is OK to drag.

Used by the tool to determine when to start a drag.