GNOME Bugzilla – Bug 343353
use arrow keys to navigate in and out of a combobox
Last modified: 2018-05-02 14:18:29 UTC
in phone environment where there are no tabulators, the arrow keys should be used to focus in and out a combobox Other information:
this bugfix is based on the solution provided by Michael Natterer for bug #322640 --- gtk/gtkcombobox.c 2005-08-18 22:10:57.000000000 +0800 +++ gtk/gtkcombobox.c 2006-05-30 11:40:40.797948947 +0800 @@ -3512,6 +3512,23 @@ gtk_combo_box_key_press (GtkWidget *wi case GDK_KP_End: found = tree_last (combo_box, combo_box->priv->model, &new_iter, FALSE); break; + case GDK_Left: + case GDK_KP_Left: + if (!gtk_widget_keynav_failed (GTK_WIDGET(combo_box), GTK_DIR_LEFT)) + { + found = FALSE; + gtk_widget_child_focus (gtk_widget_get_toplevel (GTK_WIDGET(combo_box)), GTK_DIR_TAB_BACKWARD); + } + break; + case GDK_Right: + case GDK_KP_Right: + if (!gtk_widget_keynav_failed (GTK_WIDGET(combo_box), GTK_DIR_RIGHT)) + { + found = FALSE; + gtk_widget_child_focus (gtk_widget_get_toplevel (GTK_WIDGET(combo_box)), GTK_DIR_TAB_FORWARD); + } + break; + default: return FALSE; }
Duplicate of bug 318827?
In fact, in submitting this bugfix, I was fully aware of bug 318827, but the resolution is different.
Created attachment 82524 [details] the states of a GtkComboBox
(In reply to comment #0) > in phone environment where there are no tabulators, the arrow keys should be > used to focus in and out a combobox > > Other information: > A proposal to provide pure cursor navigation: A GtkComboBox has two states (see attachment 82524 [details]): Focus-only state Focus-edit state When the focus is moved to GtkComboBox from another widget, GtkComboBox enters Focus-only state. A further ‘OK’ press will make GtkComboBox enter Focus-edit state, in which a GtkTreeView displaying a list of options will pop up for selection by ‘up’ and ‘down’ keys, the confirmation of a selection is done by the press of ‘OK’, this will also pop down the GtkTreeView and bring GtkComboBox to Focus-only state. Condition: Behaviour ‘up’ is pressed when in Focus-only state: the focus will be lost and passed to the widget immediately above GtkComboBox ‘down’ is pressed when in Focus-only state: the focus will be lost and passed to the widget immediately below GtkComboBox ‘up’ is pressed when in Focus-edit state: the arrow key navigation behaviour is defined by GtkTreeView ‘down’ is pressed when in Focus-edit state: the arrow key navigation behaviour is defined by GtkTreeView
a new patch for implementing the proposal of comment #5: --- gtk/gtkcombobox.c 2005-08-18 22:10:57.000000000 +0800 +++ gtk/gtkcombobox.c 2007-02-17 11:37:28.000000000 +0800 @@ -3464,8 +3464,8 @@ { GtkComboBox *combo_box = GTK_COMBO_BOX (data); guint state = event->state & gtk_accelerator_get_default_mod_mask (); - gboolean found; - GtkTreeIter iter; + gboolean found = FALSE; + //GtkTreeIter iter; GtkTreeIter new_iter; if (combo_box->priv->model == NULL) @@ -3483,12 +3483,12 @@ { case GDK_Down: case GDK_KP_Down: - if (gtk_combo_box_get_active_iter (combo_box, &iter)) - { - found = tree_next (combo_box, combo_box->priv->model, - &iter, &new_iter, FALSE); - break; - } + if (!gtk_widget_keynav_failed (GTK_WIDGET(combo_box), GTK_DIR_RIGHT)) + { + found = FALSE; + gtk_widget_child_focus (gtk_widget_get_toplevel (GTK_WIDGET(combo_box)), GTK_DIR_TAB_FORWARD); + } + break; /* else fall through */ case GDK_Page_Up: case GDK_KP_Page_Up: @@ -3499,12 +3499,12 @@ case GDK_Up: case GDK_KP_Up: - if (gtk_combo_box_get_active_iter (combo_box, &iter)) - { - found = tree_prev (combo_box, combo_box->priv->model, - &iter, &new_iter, FALSE); - break; - } + if (!gtk_widget_keynav_failed (GTK_WIDGET(combo_box), GTK_DIR_LEFT)) + { + found = FALSE; + gtk_widget_child_focus (gtk_widget_get_toplevel (GTK_WIDGET(combo_box)), GTK_DIR_TAB_BACKWARD); + } + break; /* else fall through */ case GDK_Page_Down: case GDK_KP_Page_Down: @@ -3512,6 +3512,7 @@ case GDK_KP_End: found = tree_last (combo_box, combo_box->priv->model, &new_iter, FALSE); break; + default: return FALSE; }
Please upload future patches using the proper form, so that they are treated as attachments and can be reviewed. My guess is these would need refreshed. I can't speculate about whether anyone would want to commit them, though. However, it can't happen in GTK+ 2 or 3, and I suspect it's unlikely to get into GTK+ 4, but I may be wrong... or just projecting how useful I find the current Up/Down behaviour of changing item without having to open the menu, though I appreciate that's not what everyone wants. :)
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/261.