button: Add explicit key bindings for activation

We should not rely on GtkWindow to have global
"activate-default" key bindings that happen to
fall back to activating the focus widget. This is
unreliable, since the bubbling up from the button
to the toplevel may run across other widgets that
may want to use Enter for their own purpose, and
then the button loses out. By adding our own
key bindings, the button gets to handle it before
its ancestors.

This fixes check buttons in the inspector property
list not reacting to Enter despite having focus.
This commit is contained in:
Matthias Clasen
2020-07-18 12:51:18 -04:00
parent 2e2336ffce
commit 7b76be5360

View File

@@ -294,6 +294,17 @@ gtk_button_class_init (GtkButtonClass *klass)
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_BUTTON_ACCESSIBLE);
gtk_widget_class_set_css_name (widget_class, I_("button"));
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_space, 0,
"activate", NULL);
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Space, 0,
"activate", NULL);
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_Return, 0,
"activate", NULL);
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_ISO_Enter, 0,
"activate", NULL);
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Enter, 0,
"activate", NULL);
}
static void