Skip to content

Gtk.EventControllerMotion

class — extends EventController

Tracks the pointer position.

The event controller offers EventControllerMotion.enter and EventControllerMotion.leave signals, as well as EventControllerMotion.is-pointer and EventControllerMotion.contains-pointer properties which are updated to reflect changes in the pointer position as it moves over the widget.

Constructors

new

@classmethod
def new(cls) -> EventController

Creates a new event controller that will handle motion events.

Methods

contains_pointer

def contains_pointer(self) -> bool

Returns if a pointer is within self or one of its children.

is_pointer

def is_pointer(self) -> bool

Returns if a pointer is within self, but not one of its children.

Properties

contains_pointer

contains_pointer: bool  # read-only

Whether the pointer is in the controllers widget or a descendant.

See also EventControllerMotion.is-pointer.

When handling crossing events, this property is updated before EventControllerMotion.enter, but after EventControllerMotion.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 EventControllerMotion.contains-pointer.

When handling crossing events, this property is updated before EventControllerMotion.enter, but after EventControllerMotion.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.