a11y: even checkable buttons are pressable
otherwise there is no way to synthesize a "click" through the a11y API. toggleAction only leads to a toggled() signal but the user may be more discerning and only listen to clicked() (or QAction::triggered) to react to **user** events not all toggle events. as such pressAction is always superior to toggleAction when user input is meant to be synthesized through a11y tooling. Change-Id: I7f024d57087b545d3cfd1805026ea538b0b3e166 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>bb10
parent
79578fd691
commit
5317ff74fd
|
|
@ -216,11 +216,9 @@ QStringList QAccessibleButton::actionNames() const
|
|||
names << toggleAction();
|
||||
break;
|
||||
default:
|
||||
if (button()->isCheckable()) {
|
||||
if (button()->isCheckable())
|
||||
names << toggleAction();
|
||||
} else {
|
||||
names << pressAction();
|
||||
}
|
||||
names << pressAction();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1118,7 +1118,10 @@ void tst_QAccessibility::buttonTest()
|
|||
interface = QAccessible::queryAccessibleInterface(&toggleButton);
|
||||
actionInterface = interface->actionInterface();
|
||||
QCOMPARE(interface->role(), QAccessible::CheckBox);
|
||||
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::toggleAction() << QAccessibleActionInterface::setFocusAction());
|
||||
QCOMPARE(actionInterface->actionNames(),
|
||||
QStringList() << QAccessibleActionInterface::toggleAction()
|
||||
<< QAccessibleActionInterface::pressAction()
|
||||
<< QAccessibleActionInterface::setFocusAction());
|
||||
QCOMPARE(actionInterface->localizedActionDescription(QAccessibleActionInterface::toggleAction()), QString("Toggles the state"));
|
||||
QVERIFY(!toggleButton.isChecked());
|
||||
QVERIFY(!interface->state().checked);
|
||||
|
|
@ -1154,12 +1157,18 @@ void tst_QAccessibility::buttonTest()
|
|||
interface = QAccessible::queryAccessibleInterface(&checkBox);
|
||||
actionInterface = interface->actionInterface();
|
||||
QCOMPARE(interface->role(), QAccessible::CheckBox);
|
||||
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::toggleAction() << QAccessibleActionInterface::setFocusAction());
|
||||
QCOMPARE(actionInterface->actionNames(),
|
||||
QStringList() << QAccessibleActionInterface::toggleAction()
|
||||
<< QAccessibleActionInterface::pressAction()
|
||||
<< QAccessibleActionInterface::setFocusAction());
|
||||
QVERIFY(!interface->state().checked);
|
||||
actionInterface->doAction(QAccessibleActionInterface::toggleAction());
|
||||
|
||||
QTest::qWait(500);
|
||||
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::toggleAction() << QAccessibleActionInterface::setFocusAction());
|
||||
QCOMPARE(actionInterface->actionNames(),
|
||||
QStringList() << QAccessibleActionInterface::toggleAction()
|
||||
<< QAccessibleActionInterface::pressAction()
|
||||
<< QAccessibleActionInterface::setFocusAction());
|
||||
QVERIFY(interface->state().checked);
|
||||
QVERIFY(checkBox.isChecked());
|
||||
QAccessible::State st;
|
||||
|
|
|
|||
Loading…
Reference in New Issue