GtkEventControllerFocus

GtkEventControllerFocus — Event controller for focus

Properties

gboolean contains-focus Read
gboolean is-focus Read

Signals

void enter Run Last
void leave Run Last

Types and Values

Object Hierarchy

    GObject
    ╰── GtkEventController
        ╰── GtkEventControllerFocus

Includes

#include <gtk/gtk.h>

Description

GtkEventControllerFocus is an event controller meant for situations where you need to know where the focus is.

Functions

gtk_event_controller_focus_new ()

GtkEventController *
gtk_event_controller_focus_new (void);

Creates a new event controller that will handle focus events.

Returns

a new GtkEventControllerFocus

gtk_event_controller_focus_contains_focus ()

gboolean
gtk_event_controller_focus_contains_focus
                               (GtkEventControllerFocus *self);

Returns the value of the GtkEventControllerFocus:contains-focus property.

Parameters

Returns

TRUE if focus is within self or one of its children

gtk_event_controller_focus_is_focus ()

gboolean
gtk_event_controller_focus_is_focus (GtkEventControllerFocus *self);

Returns the value of the GtkEventControllerFocus:is-focus property.

Parameters

Returns

TRUE if focus is within self but not one of its children

Types and Values

GtkEventControllerFocus

typedef struct _GtkEventControllerFocus GtkEventControllerFocus;

Property Details

The “contains-focus” property

  “contains-focus”           gboolean

Whether focus is contain in the controllers widget. See See “is-focus” for whether the focus is in the widget itself or inside a descendent.

When handling focus events, this property is updated before “enter” or “leave” are emitted.

Owner: GtkEventControllerFocus

Flags: Read

Default value: FALSE

The “is-focus” property

  “is-focus”                 gboolean

Whether focus is in the controllers widget itself, opposed to in a descendent widget. See also “contains-focus”.

When handling focus events, this property is updated before “enter” or “leave” are emitted.

Owner: GtkEventControllerFocus

Flags: Read

Default value: FALSE

Signal Details

The “enter” signal

void
user_function (GtkEventControllerFocus *controller,
               gpointer                 user_data)

This signal is 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 “is-focus” property for changes.

Parameters

controller

the object which received the signal

user_data

user data set when the signal handler was connected.

Flags: Run Last

The “leave” signal

void
user_function (GtkEventControllerFocus *controller,
               gpointer                 user_data)

This signal is 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 “is-focus” property for changes.

Parameters

controller

the object which received the signal

user_data

user data set when the signal handler was connected.

Flags: Run Last

© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk4/4.0/GtkEventControllerFocus.html