[gtk/gtk-4-2: 5/91] button: Add back visual feedback for keynav
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-4-2: 5/91] button: Add back visual feedback for keynav
- Date: Tue, 4 May 2021 02:05:40 +0000 (UTC)
commit 1506a41448b9634c1a02d671df6f43159e2de623
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Apr 1 18:36:23 2021 -0400
button: Add back visual feedback for keynav
We lost the visual feedback for activating a button
via Space or Enter when the :active pseudo-state became
managed. Bring it back with a style class.
Fixes: #3813
gtk/gtkbutton.c | 6 ++++++
gtk/theme/Adwaita/_common.scss | 1 +
2 files changed, 7 insertions(+)
---
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 3b2aad8f34..1acc35d569 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -39,6 +39,8 @@
* `GtkButton` has a single CSS node with name button. The node will get the
* style classes .image-button or .text-button, if the content is just an
* image or label, respectively. It may also receive the .flat style class.
+ * When activating a button via the keyboard, the button will temporarily
+ * gain the .keyboard-activating style class.
*
* Other style classes that are commonly used with `GtkButton` include
* .suggested-action and .destructive-action. In special cases, buttons
@@ -780,6 +782,8 @@ gtk_real_button_activate (GtkButton *button)
{
priv->activate_timeout = g_timeout_add (ACTIVATE_TIMEOUT, button_activate_timeout, button);
g_source_set_name_by_id (priv->activate_timeout, "[gtk] button_activate_timeout");
+
+ gtk_widget_add_css_class (GTK_WIDGET (button), "keyboard-activating");
priv->button_down = TRUE;
}
}
@@ -790,6 +794,8 @@ gtk_button_finish_activate (GtkButton *button,
{
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
+ gtk_widget_remove_css_class (GTK_WIDGET (button), "keyboard-activating");
+
g_source_remove (priv->activate_timeout);
priv->activate_timeout = 0;
diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss
index c5baa58518..ea4c31f6d1 100644
--- a/gtk/theme/Adwaita/_common.scss
+++ b/gtk/theme/Adwaita/_common.scss
@@ -492,6 +492,7 @@ button {
-gtk-icon-filter: brightness(1.2);
}
+ &.keyboard-activating,
&:active,
&:checked {
@include button(active);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]