checkbutton: Activate when moving focus

Currently we update the :active property on both the previous and
new focus button. That "visually activate" the button and will
emit ::toggled, but if the button is associated with an action,
the action state won't change.

Fix that by activating the new focus instead of explicitly fiddling
with the :active property.
This commit is contained in:
Florian Müllner 2021-07-30 20:18:36 +02:00
parent c50475de34
commit 1728aa581c

View File

@ -420,9 +420,6 @@ gtk_check_button_focus (GtkWidget *widget,
GtkDirectionType direction) GtkDirectionType direction)
{ {
GtkCheckButton *self = GTK_CHECK_BUTTON (widget); GtkCheckButton *self = GTK_CHECK_BUTTON (widget);
GtkCheckButton *active_button;
active_button = get_group_active_button (self);
if (gtk_widget_is_focus (widget)) if (gtk_widget_is_focus (widget))
{ {
@ -471,9 +468,7 @@ gtk_check_button_focus (GtkWidget *widget,
if (new_focus) if (new_focus)
{ {
gtk_widget_grab_focus (new_focus); gtk_widget_grab_focus (new_focus);
gtk_check_button_set_active (GTK_CHECK_BUTTON (new_focus), TRUE); gtk_widget_activate (new_focus);
if (active_button && active_button != (GtkCheckButton *)new_focus)
gtk_check_button_set_active (GTK_CHECK_BUTTON (active_button), FALSE);
} }
g_ptr_array_free (child_array, TRUE); g_ptr_array_free (child_array, TRUE);
@ -482,6 +477,9 @@ gtk_check_button_focus (GtkWidget *widget,
} }
else else
{ {
GtkCheckButton *active_button;
active_button = get_group_active_button (self);
if (active_button && active_button != self) if (active_button && active_button != self)
return FALSE; return FALSE;