After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 343353 - use arrow keys to navigate in and out of a combobox
use arrow keys to navigate in and out of a combobox
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkComboBox
3.91.x
Other All
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2006-05-30 03:46 UTC by gang
Modified: 2018-05-02 14:18 UTC
See Also:
GNOME target: ---
GNOME version: 2.7/2.8


Attachments
the states of a GtkComboBox (9.19 KB, image/jpeg)
2007-02-14 10:19 UTC, gang
Details

Description gang 2006-05-30 03:46:50 UTC
in phone environment where there are no tabulators, the arrow keys should be
used to focus in and out a combobox

Other information:
Comment 1 gang 2006-05-30 03:50:10 UTC
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;
     }
Comment 2 Elijah Newren 2006-05-30 23:28:57 UTC
Duplicate of bug 318827?
Comment 3 gang 2006-05-31 08:17:38 UTC
In fact, in submitting this bugfix, I was fully aware of bug 318827, but the resolution is different.
Comment 4 gang 2007-02-14 10:19:50 UTC
Created attachment 82524 [details]
the states of a GtkComboBox
Comment 5 gang 2007-02-14 10:24:33 UTC
(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
Comment 6 gang 2007-02-17 03:46:58 UTC
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;
     }
Comment 7 Daniel Boles 2017-08-15 15:10:02 UTC
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. :)
Comment 8 GNOME Infrastructure Team 2018-05-02 14:18:29 UTC
-- 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.