diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-04-18 14:02:25 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-04-20 15:28:58 +0200 |
commit | 1e851093f0148d2c55fc3fd377d274f6703c71c9 (patch) | |
tree | 9210f657b3e25987cffcc07c8c6b90018a404f97 | |
parent | 9bb46a8e9819fa74dee53b305a4255bb72a89e22 (diff) |
tdf#159910 gtk3 a11y: Keep a11y props for combobox
Due to various issues with GtkComboBox, the gtk3 VCL
plugin does not use the original GtkComboBox, but a
custom implementation, originally
introduced in
commit bc0e0f633b05c4f91b6695488fc9e5c127507ba5
Date: Thu Apr 9 11:41:00 2020 +0100
tdf#131120 use a replacement for GtkComboBox
(See full commit message for more details and reasons.)
This means that the accessible role, name and description
from the .ui file are not set automatically for the
GtkToggleButton widget that acts as the combobox
instead and receives keyboard focus.
In order to make these available for AT, explicitly
take these over from the original GtkComboBox.
With this in place, the Orca screen reader now
e.g. properly announces the comboboxes in Writer's
Navigator as "Navigate By, combobox" and
"Active window, combobox" (similar to how it already
does for the qt6 VCL plugin), rather than just saying
"toggle button, not pressed", which didn't give any hint
to the user what the currently focused UI element
is about and how to interact with it.
Also set a default a11y role of combo-box in
the replacement's .ui file. (The role from
the GtkComboBox's AtkObject should always override
that in practice, though.)
Change-Id: If5faf77c5f82836c376c04bb6e4e42ce5a3023a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166248
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
-rw-r--r-- | vcl/uiconfig/ui/combobox.ui | 5 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtkinst.cxx | 12 |
2 files changed, 17 insertions, 0 deletions
diff --git a/vcl/uiconfig/ui/combobox.ui b/vcl/uiconfig/ui/combobox.ui index a0b72e27821f..6abaa6a25171 100644 --- a/vcl/uiconfig/ui/combobox.ui +++ b/vcl/uiconfig/ui/combobox.ui @@ -51,6 +51,11 @@ </child> </object> </child> + <child internal-child="accessible"> + <object class="AtkObject" id="button-atkobject"> + <property name="AtkObject::accessible-role">combo-box</property> + </object> + </child> <style> <class name="combo"/> </style> diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index f35dad49d141..bcdcbc1c6157 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -22172,6 +22172,18 @@ public: g_signal_connect(getContainer(), "query-tooltip", G_CALLBACK(signalComboTooltipQuery), this); } + if (AtkObject* pComboBoxAccessible = gtk_widget_get_accessible(GTK_WIDGET(m_pComboBox))) + { + if (AtkObject* pToggleButtonAccessible = gtk_widget_get_accessible(GTK_WIDGET(m_pToggleButton))) + { + atk_object_set_role(pToggleButtonAccessible, atk_object_get_role(pComboBoxAccessible)); + if (const char* pName = atk_object_get_name(pComboBoxAccessible)) + atk_object_set_name(pToggleButtonAccessible, pName); + if (const char* pDesc = atk_object_get_description(pComboBoxAccessible)) + atk_object_set_description(pToggleButtonAccessible, pDesc); + } + } + insertAsParent(GTK_WIDGET(m_pComboBox), GTK_WIDGET(getContainer())); gtk_widget_set_visible(GTK_WIDGET(m_pComboBox), false); gtk_widget_set_no_show_all(GTK_WIDGET(m_pComboBox), true); |