Accessibility: Fix select state usage

The selectable/selected states refer to items in a list and similar,
do not interpret them as text selection states.
Without this change NVDA for example announces text edits as selected
which makes no sense and which it doesn't do for native text items.

Change-Id: Ib1d109523bd4cc2b9b40ace8a8c3d7d3a7f9f25c
Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
This commit is contained in:
Frederik Gladhorn 2014-05-30 14:13:30 +02:00 committed by The Qt Project
parent 739ad76846
commit bb794270ec
4 changed files with 13 additions and 6 deletions

View File

@ -176,7 +176,7 @@ QT_BEGIN_NAMESPACE
\value readOnly The object can usually be edited, but is explicitly set to read-only.
\value selectable The object is selectable.
\value selectableText The object has text which can be selected. This is different from selectable which refers to the object's children.
\value selected The object is selected.
\value selected The object is selected, this is independent of text selection.
\value selfVoicing The object describes itself through speech or sound.
\value sizeable The object can be resized, e.g. top-level windows.
\value summaryElement The object summarizes the state of the window and should be treated with priority.

View File

@ -652,6 +652,7 @@ QAccessibleTextWidget::QAccessibleTextWidget(QWidget *o, QAccessible::Role r, co
QAccessible::State QAccessibleTextWidget::state() const
{
QAccessible::State s = QAccessibleWidget::state();
s.selectableText = true;
s.multiLine = true;
return s;
}

View File

@ -663,10 +663,8 @@ QAccessible::State QAccessibleLineEdit::state() const
if (l->echoMode() != QLineEdit::Normal)
state.passwordEdit = true;
state.selectable = true;
if (l->hasSelectedText())
state.selected = true;
state.selectableText = true;
return state;
}

View File

@ -1659,6 +1659,11 @@ void tst_QAccessibility::textEditTest()
QTest::qWaitForWindowShown(&edit);
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(&edit);
QCOMPARE(iface->text(QAccessible::Value), edit.toPlainText());
QVERIFY(iface->state().focusable);
QVERIFY(!iface->state().selectable);
QVERIFY(!iface->state().selected);
QVERIFY(iface->state().selectableText);
QAccessibleTextInterface *textIface = iface->textInterface();
QVERIFY(textIface);
@ -1936,7 +1941,8 @@ void tst_QAccessibility::lineEditTest()
QVERIFY(iface->state().sizeable);
QVERIFY(iface->state().movable);
QVERIFY(iface->state().focusable);
QVERIFY(iface->state().selectable);
QVERIFY(!iface->state().selectable);
QVERIFY(iface->state().selectableText);
QVERIFY(!iface->state().hasPopup);
QCOMPARE(bool(iface->state().focused), le->hasFocus());
@ -1964,7 +1970,9 @@ void tst_QAccessibility::lineEditTest()
QVERIFY(!(iface->state().sizeable));
QVERIFY(!(iface->state().movable));
QVERIFY(iface->state().focusable);
QVERIFY(iface->state().selectable);
QVERIFY(!iface->state().selectable);
QVERIFY(!iface->state().selected);
QVERIFY(iface->state().selectableText);
QVERIFY(!iface->state().hasPopup);
QCOMPARE(bool(iface->state().focused), le->hasFocus());