aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2022-02-21 16:02:58 +0100
committerIvan Solovev <ivan.solovev@qt.io>2022-03-06 15:34:46 +0100
commitc4f02e37124502828be7b754ad327d8b22abacd4 (patch)
treef5cb6e3fbbaea8441c357bbf65b4a1d78ccb7979 /src/quick
parent0008a6a9d24e56e085c32acd1b514d78460757d0 (diff)
A11Y: make QQuickText focusable for A11Y
A QtQuick Text element is used to represent a separate block of text in a window. Normally, when TalkBack is enabled, the user expects to be able to navigate between separate blocks of text with regular A11Y gestures. However before this patch the Text elements were not focusable by default, so all the Text elements in the Window were read by the TalkBack successively, as if it was one element. This could be solved by explicitly adding Accessible.focusable: true to the properties of every Text element. This patch enables A11Y focus on Text elements by default. Fixes: QTBUG-77371 Change-Id: Icfcef6ee301b9218bb9ace97a05432c9fc2ffb0a Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit 9c5f772b5eb008cd0d00a0801b80a399fdc0e3c9)
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/accessible/qaccessiblequickitem.cpp7
-rw-r--r--src/quick/items/qquickaccessibleattached.cpp5
2 files changed, 9 insertions, 3 deletions
diff --git a/src/quick/accessible/qaccessiblequickitem.cpp b/src/quick/accessible/qaccessiblequickitem.cpp
index d37b276496..3d89d33769 100644
--- a/src/quick/accessible/qaccessiblequickitem.cpp
+++ b/src/quick/accessible/qaccessiblequickitem.cpp
@@ -177,6 +177,11 @@ QList<QQuickItem *> QAccessibleQuickItem::childItems() const
return accessibleUnignoredChildren(item());
}
+static bool isTextRole(QAccessible::Role role)
+{
+ return role == QAccessible::EditableText || role == QAccessible::StaticText;
+}
+
QAccessible::State QAccessibleQuickItem::state() const
{
QQuickAccessibleAttached *attached = QQuickAccessibleAttached::attachedProperties(item());
@@ -194,7 +199,7 @@ QAccessible::State QAccessibleQuickItem::state() const
state.offscreen = true;
if ((role() == QAccessible::CheckBox || role() == QAccessible::RadioButton) && object()->property("checked").toBool())
state.checked = true;
- if (item()->activeFocusOnTab() || role() == QAccessible::EditableText)
+ if (item()->activeFocusOnTab() || isTextRole(role()))
state.focusable = true;
if (item()->hasActiveFocus())
state.focused = true;
diff --git a/src/quick/items/qquickaccessibleattached.cpp b/src/quick/items/qquickaccessibleattached.cpp
index fbdb17c7b9..38c2310c2b 100644
--- a/src/quick/items/qquickaccessibleattached.cpp
+++ b/src/quick/items/qquickaccessibleattached.cpp
@@ -406,9 +406,10 @@ void QQuickAccessibleAttached::setRole(QAccessible::Role role)
m_state.focusable = true;
break;
case QAccessible::StaticText:
- if (!m_stateExplicitlySet.readOnly) {
+ if (!m_stateExplicitlySet.readOnly)
m_state.readOnly = true;
- }
+ if (!m_stateExplicitlySet.focusable)
+ m_state.focusable = true;
break;
default:
break;