Gtk.EventControllerFocus

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

Subclasses:

None

Methods

Inherited:

Gtk.EventController (13), GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

contains_focus ()

is_focus ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Inherited:

Gtk.EventController (4)

Name

Type

Flags

Short Description

contains-focus

bool

r

is-focus

bool

r

Signals

Inherited:

GObject.Object (1)

Name

Short Description

enter

Emitted whenever the focus enters into the widget or one of its descendents.

leave

Emitted whenever the focus leaves the widget hierarchy that is rooted at the widget that the controller is attached to.

Fields

Inherited:

GObject.Object (1)

Class Details

class Gtk.EventControllerFocus(**kwargs)
Bases:

Gtk.EventController

Abstract:

No

Structure:

Gtk.EventControllerFocusClass

GtkEventControllerFocus is an event controller to keep track of keyboard focus.

The event controller offers [signal`Gtk`.EventControllerFocus::enter] and [signal`Gtk`.EventControllerFocus::leave] signals, as well as [property`Gtk`.EventControllerFocus:is-focus] and [property`Gtk`.EventControllerFocus:contains-focus] properties which are updated to reflect focus changes inside the widget hierarchy that is rooted at the controllers widget.

classmethod new()[source]
Returns:

a new GtkEventControllerFocus

Return type:

Gtk.EventController

Creates a new event controller that will handle focus events.

contains_focus()[source]
Returns:

True if focus is within self or one of its children

Return type:

bool

Returns True if focus is within self or one of its children.

is_focus()[source]
Returns:

True if focus is within self, but not one of its children

Return type:

bool

Returns True if focus is within self, but not one of its children.

Signal Details

Gtk.EventControllerFocus.signals.enter(event_controller_focus)
Signal Name:

enter

Flags:

RUN_LAST

Parameters:

event_controller_focus (Gtk.EventControllerFocus) – The object which received the signal

Emitted whenever the focus enters into the widget or one of its descendents.

Note that this means you may not get an ::enter signal even though the widget becomes the focus location, in certain cases (such as when the focus moves from a descendent of the widget to the widget itself). If you are interested in these cases, you can monitor the [property`Gtk`.EventControllerFocus:is-focus] property for changes.

Gtk.EventControllerFocus.signals.leave(event_controller_focus)
Signal Name:

leave

Flags:

RUN_LAST

Parameters:

event_controller_focus (Gtk.EventControllerFocus) – The object which received the signal

Emitted whenever the focus leaves the widget hierarchy that is rooted at the widget that the controller is attached to.

Note that this means you may not get a ::leave signal even though the focus moves away from the widget, in certain cases (such as when the focus moves from the widget to a descendent). If you are interested in these cases, you can monitor the [property`Gtk`.EventControllerFocus:is-focus] property for changes.

Property Details

Gtk.EventControllerFocus.props.contains_focus
Name:

contains-focus

Type:

bool

Default Value:

False

Flags:

READABLE

True if focus is contained in the controllers widget.

See [property`Gtk`.EventControllerFocus:is-focus] for whether the focus is in the widget itself or inside a descendent.

When handling focus events, this property is updated before [signal`Gtk`.EventControllerFocus::enter] or [signal`Gtk`.EventControllerFocus::leave] are emitted.

Gtk.EventControllerFocus.props.is_focus
Name:

is-focus

Type:

bool

Default Value:

False

Flags:

READABLE

True if focus is in the controllers widget itself, as opposed to in a descendent widget.

See also [property`Gtk`.EventControllerFocus:contains-focus].

When handling focus events, this property is updated before [signal`Gtk`.EventControllerFocus::enter] or [signal`Gtk`.EventControllerFocus::leave] are emitted.