Skip to content

Gtk.GestureDrag

class — extends GestureSingle

Recognizes drag gestures.

The drag operation itself can be tracked throughout the GestureDrag.drag-begin, GestureDrag.drag-update and GestureDrag.drag-end signals, and the relevant coordinates can be extracted through GestureDrag.get_offset and GestureDrag.get_start_point.

Constructors

new

@classmethod
def new(cls) -> Gesture

Returns a newly created GtkGesture that recognizes drags.

Methods

get_offset

def get_offset(self) -> tuple[bool, float, float]

Gets the offset from the start point.

If the gesture is active, this function returns True and fills in x and y with the coordinates of the current point, as an offset to the starting drag point.

get_start_point

def get_start_point(self) -> tuple[bool, float, float]

Gets the point where the drag started.

If the gesture is active, this function returns True and fills in x and y with the drag start coordinates, in widget-relative coordinates.

Signals

drag-begin

def on_drag_begin(self, start_x: float, start_y: float) -> None: ...

Emitted whenever dragging starts.

drag-end

def on_drag_end(self, offset_x: float, offset_y: float) -> None: ...

Emitted whenever the dragging is finished.

drag-update

def on_drag_update(self, offset_x: float, offset_y: float) -> None: ...

Emitted whenever the dragging point moves.