Package: gtk

Function gtk:widget-keynav-failed

Lambda List

gtk:widget-keynav-failed (widget direction)

Arguments

widget -- a gtk:widget object
direction -- a gtk:direction-type value for the direction of focus movement

Return Value

True if stopping keyboard navigation is fine, false if the emitting widget should try to handle the keyboard navigation attempt in its parent container(s).

Details

Emits the "notify::keynav-failed" signal on the widget. This function should be called whenever keyboard navigation within a single widget hits a boundary.

The return value of this function should be interpreted in a way similar to the return value of gtk:widget-child-focus function. When true is returned, stay in the widget, the failed keyboard navigation is OK and/or there is nowhere we can/should move the focus to. When false is returned, the caller should continue with keyboard navigation outside the widget, for example, by calling the gtk:widget-child-focus function on the toplevel of the widget.

The default "keynav-failed" signal handler returns false for the :tab-forward and :tab-backward values of the gtk:direction-type enumeration. For the other values of the gtk:direction-type enumeration it returns true.

Whenever the default handler returns true, it also calls the gtk:widget-error-bell function to notify the user of the failed keyboard navigation.

A use case for providing an own implementation of the "keynav-failed" signal handler (either by connecting to it or by overriding it) would be a row of gtk:entry widgets where the user should be able to navigate the entire row with the cursor keys, as for example, known from user interfaces that require entering license keys.
 

See also

2025-2-13