From f70f321c8b5769476796e2bae540a57b3b62c684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 7 Jul 2009 11:39:43 +0200 Subject: Make sure we send a ValueChanged event if the spinbox value has changed Unfortunately the codepath for keyPressEvent does not call updateState, so we have to add the same line in two places. Note that updateState() is only called from mousePressEvent() and mouseMoveEvent(). Task-number: 254053 --- src/gui/widgets/qabstractspinbox.cpp | 9 +++++++++ tests/auto/qaccessibility/tst_qaccessibility.cpp | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/src/gui/widgets/qabstractspinbox.cpp b/src/gui/widgets/qabstractspinbox.cpp index 25acd6e..da18d13 100644 --- a/src/gui/widgets/qabstractspinbox.cpp +++ b/src/gui/widgets/qabstractspinbox.cpp @@ -57,6 +57,9 @@ #include #include #include +#ifndef QT_NO_ACCESSIBILITY +# include +#endif #if defined(Q_WS_X11) #include @@ -951,6 +954,9 @@ void QAbstractSpinBox::keyPressEvent(QKeyEvent *event) d->buttonState = (Keyboard | (up ? Up : Down)); } stepBy(steps); +#ifndef QT_NO_ACCESSIBILITY + QAccessible::updateAccessibility(this, 0, QAccessible::ValueChanged); +#endif return; } #ifdef QT_KEYPAD_NAVIGATION @@ -1548,6 +1554,9 @@ void QAbstractSpinBoxPrivate::updateState(bool up) spinClickThresholdTimerId = q->startTimer(spinClickThresholdTimerInterval); buttonState = (up ? (Mouse | Up) : (Mouse | Down)); q->stepBy(up ? 1 : -1); +#ifndef QT_NO_ACCESSIBILITY + QAccessible::updateAccessibility(q, 0, QAccessible::ValueChanged); +#endif } } diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index 8a88b59..b8aec50 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -2623,6 +2623,13 @@ void tst_QAccessibility::spinBoxTest() QVERIFY(childRect.isNull() == false); } + spinBox->setFocus(); + QTestAccessibility::clearEvents(); + QTest::keyPress(spinBox, Qt::Key_Up); + QTest::qWait(200); + EventList events = QTestAccessibility::events(); + QTestAccessibilityEvent expectedEvent(spinBox, 0, (int)QAccessible::ValueChanged); + QVERIFY(events.contains(expectedEvent)); delete spinBox; QTestAccessibility::clearEvents(); #else -- cgit v0.12