Gtk.EventController

g GObject.Object GObject.Object Gtk.EventController Gtk.EventController GObject.Object->Gtk.EventController

Subclasses:

Gtk.DropControllerMotion, Gtk.DropTarget, Gtk.DropTargetAsync, Gtk.EventControllerFocus, Gtk.EventControllerKey, Gtk.EventControllerLegacy, Gtk.EventControllerMotion, Gtk.EventControllerScroll, Gtk.Gesture, Gtk.PadController, Gtk.ShortcutController

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

get_current_event ()

get_current_event_device ()

get_current_event_state ()

get_current_event_time ()

get_name ()

get_propagation_limit ()

get_propagation_phase ()

get_widget ()

reset ()

set_name (name)

set_propagation_limit (limit)

set_propagation_phase (phase)

set_static_name (name)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

name

str

r/w

propagation-limit

Gtk.PropagationLimit

r/w/en

propagation-phase

Gtk.PropagationPhase

r/w/en

widget

Gtk.Widget

r

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Gtk.EventController(**kwargs)
Bases:

GObject.Object

Abstract:

Yes

Structure:

Gtk.EventControllerClass

GtkEventController is the base class for event controllers.

These are ancillary objects associated to widgets, which react to GdkEvents, and possibly trigger actions as a consequence.

Event controllers are added to a widget with [method`Gtk`.Widget.add_controller]. It is rarely necessary to explicitly remove a controller with [method`Gtk`.Widget.remove_controller].

See the chapter on input handling for an overview of the basic concepts, such as the capture and bubble phases of event propagation.

get_current_event()[source]
Returns:

the event that is currently handled by self

Return type:

Gdk.Event or None

Returns the event that is currently being handled by the controller.

At other times, None is returned.

get_current_event_device()[source]
Returns:

device of the event is currently handled by self

Return type:

Gdk.Device or None

Returns the device of the event that is currently being handled by the controller.

At other times, None is returned.

get_current_event_state()[source]
Returns:

modifier state of the event is currently handled by self

Return type:

Gdk.ModifierType

Returns the modifier state of the event that is currently being handled by the controller.

At other times, 0 is returned.

get_current_event_time()[source]
Returns:

timestamp of the event is currently handled by self

Return type:

int

Returns the timestamp of the event that is currently being handled by the controller.

At other times, 0 is returned.

get_name()[source]
Returns:

The controller name

Return type:

str or None

Gets the name of self.

get_propagation_limit()[source]
Returns:

the propagation limit

Return type:

Gtk.PropagationLimit

Gets the propagation limit of the event controller.

get_propagation_phase()[source]
Returns:

the propagation phase

Return type:

Gtk.PropagationPhase

Gets the propagation phase at which self handles events.

get_widget()[source]
Returns:

a GtkWidget

Return type:

Gtk.Widget

Returns the GtkWidget this controller relates to.

reset()[source]

Resets the self to a clean state.

set_name(name)[source]
Parameters:

name (str or None) – a name for self

Sets a name on the controller that can be used for debugging.

set_propagation_limit(limit)[source]
Parameters:

limit (Gtk.PropagationLimit) – the propagation limit

Sets the event propagation limit on the event controller.

If the limit is set to Gtk.PropagationLimit.SAME_NATIVE, the controller won’t handle events that are targeted at widgets on a different surface, such as popovers.

set_propagation_phase(phase)[source]
Parameters:

phase (Gtk.PropagationPhase) – a propagation phase

Sets the propagation phase at which a controller handles events.

If phase is Gtk.PropagationPhase.NONE, no automatic event handling will be performed, but other additional gesture maintenance will.

set_static_name(name)[source]
Parameters:

name (str or None) – a name for self, must be a static string

Sets a name on the controller that can be used for debugging.

New in version 4.8.

Property Details

Gtk.EventController.props.name
Name:

name

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The name for this controller, typically used for debugging purposes.

Gtk.EventController.props.propagation_limit
Name:

propagation-limit

Type:

Gtk.PropagationLimit

Default Value:

Gtk.PropagationLimit.SAME_NATIVE

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The limit for which events this controller will handle.

Gtk.EventController.props.propagation_phase
Name:

propagation-phase

Type:

Gtk.PropagationPhase

Default Value:

Gtk.PropagationPhase.BUBBLE

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The propagation phase at which this controller will handle events.

Gtk.EventController.props.widget
Name:

widget

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE

The widget receiving the GdkEvents that the controller will handle.