Skip to content

Gtk.DropControllerMotion

class — extends EventController

An event controller tracking the pointer during Drag-and-Drop operations.

It is modeled after EventControllerMotion so if you have used that, this should feel really familiar.

This controller is not able to accept drops, use DropTarget for that purpose.

Constructors

new

@classmethod
def new(cls) -> EventController

Creates a new event controller that will handle pointer motion events during drag and drop.

Methods

contains_pointer

def contains_pointer(self) -> bool

Returns if a Drag-and-Drop operation is within the widget self or one of its children.

get_drop

def get_drop(self) -> Gdk.Drop | None

Returns the GdkDrop of a current Drag-and-Drop operation over the widget of self.

is_pointer

def is_pointer(self) -> bool

Returns if a Drag-and-Drop operation is within the widget self, not one of its children.

Properties

contains_pointer

contains_pointer: bool  # read-only

Whether the pointer of a Drag-and-Drop operation is in the controller's widget or a descendant.

See also DropControllerMotion.is-pointer.

When handling crossing events, this property is updated before DropControllerMotion.enter, but after DropControllerMotion.leave is emitted.

drop

drop: Gdk.Drop  # read-only

The ongoing drop operation over the controller's widget or its descendant.

If no drop operation is going on, this property returns None.

The event controller should not modify the drop, but it might want to query its properties.

When handling crossing events, this property is updated before DropControllerMotion.enter, but after DropControllerMotion.leave is emitted.

is_pointer

is_pointer: bool  # read-only

Whether the pointer is in the controllers widget itself, as opposed to in a descendent widget.

See also DropControllerMotion.contains-pointer.

When handling crossing events, this property is updated before DropControllerMotion.enter, but after DropControllerMotion.leave is emitted.

Signals

enter

def on_enter(self, x: float, y: float) -> None: ...

Signals that the pointer has entered the widget.

leave

def on_leave(self) -> None: ...

Signals that the pointer has left the widget.

motion

def on_motion(self, x: float, y: float) -> None: ...

Emitted when the pointer moves inside the widget.