Allow selectable labels contents to be selected by mnemonic
authorCaolán McNamara <caolanm@redhat.com>
Wed, 18 May 2022 11:40:40 +0000 (12:40 +0100)
committerCaolán McNamara <caolanm@redhat.com>
Wed, 18 May 2022 11:40:40 +0000 (12:40 +0100)
expecially by the mnemonic of another label that targets it.

https://gitlab.gnome.org/GNOME/gtk/-/issues/4927

see also https://bugs.documentfoundation.org/show_bug.cgi?id=137748

gtk/gtklabel.c

index ac2554937047235d087ba8b0abcf323677a16ad5..46a909c794fdd1c0a1492a40bd9b5f202f785f1f 100644 (file)
@@ -2020,6 +2020,12 @@ gtk_label_mnemonic_activate (GtkWidget *widget,
   if (self->mnemonic_widget)
     return gtk_widget_mnemonic_activate (self->mnemonic_widget, group_cycling);
 
+  /* Not a label for something else, but is selectable, so set focus into
+   * the label itself.
+  */
+  if (gtk_label_get_selectable (self) && gtk_widget_get_focusable (widget))
+    return gtk_label_grab_focus (widget);
+
   /* Try to find the widget to activate by traversing the
    * widget's ancestry.
    */