Android: Avoid announcing simple text as clickable

The definition of Accessible.onPressAction is enough to let
Android announce an element as clickable. But this is a
problem when components are designied in a way like this:
  Accessible.role: clickable ? Accessible.Button : Accessible.StaticText
  Accessible.onPressAction: clickable ? doit() : nothing()
So we avoid to set clickable for StaticText and Heading.
Windows, macOS and iOS already have the right behavior and do
not care about pressAction or toggleAction on simple text.

Pick-to: 6.10 6.9 6.8
Change-Id: I7bf9ffae112b92dd4a90f51f014a348dfe1b63f3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Lars Schmertmann 2025-09-15 16:06:43 +02:00 committed by Tor Arne Vestbø
parent 7ae2b8bc44
commit ac7b5815db
1 changed files with 3 additions and 2 deletions

View File

@ -699,8 +699,9 @@ namespace QtAndroidAccessibility
env->CallVoidMethod(node, m_setClassNameMethodID, jrole); env->CallVoidMethod(node, m_setClassNameMethodID, jrole);
const bool hasClickableAction = const bool hasClickableAction =
info.actions.contains(QAccessibleActionInterface::pressAction()) || (info.actions.contains(QAccessibleActionInterface::pressAction())
info.actions.contains(QAccessibleActionInterface::toggleAction()); || info.actions.contains(QAccessibleActionInterface::toggleAction()))
&& !(info.role == QAccessible::StaticText || info.role == QAccessible::Heading);
const bool hasIncreaseAction = const bool hasIncreaseAction =
info.actions.contains(QAccessibleActionInterface::increaseAction()); info.actions.contains(QAccessibleActionInterface::increaseAction());
const bool hasDecreaseAction = const bool hasDecreaseAction =