Gtk.Widget.prototype.keynav_failed
function keynav_failed(direction:Gtk.DirectionType):Boolean { // Gjs wrapper for gtk_widget_keynav_failed() }
This function should be called whenever keyboard navigation within a single widget hits a boundary. The function emits the Gtk.keynav-failed signal on the widget and its return value should be interpreted in a way similar to the return value of Gtk.Widget.prototype.child_focus:
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 Gtk.Widget.prototype.child_focus on the widget's toplevel.
The default ::keynav-failed handler returns true for Gtk.DirectionType.tab_forward and Gtk.DirectionType.tab_backward. For the other values of Gtk.DirectionType, it looks at the Gtk.Settings: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 Gtk.Widget.prototype.error_bell 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.
Since 2.12
- direction
direction of focus movement
- Returns
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).