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

This function should be called whenever keyboard navigation within a single widget hits a boundary. The function emits the "keynav-failed" signal on the widget and its return value should be interpreted in a way similar to the return value of the 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, e.g. by calling the gtk-widget-child-focus function on the toplevel of the widget.
The default "keynav-failed" handler returns true for :tab-forward and :tab-backward. For the other gtk-direction-type values, it looks at the gtk-keynav-cursor-only setting and returns false if the setting is true. This way the entire user interface becomes cursor-navigatable on input devices such as mobile phones which only have cursor keys but no tab key.

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 "keynav-failed", 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 e.g. known from user interfaces that require entering license keys.
 

See also

2021-9-20