Update accessibility selections in QTextControl.
Forwardport from Qt 4. Change-Id: Iae0c2792b64b8ec2736a9ff621cf7c313a394093 Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com> (cherry picked from commit d5649547d641b9c5af3c3f814caf8e1ab5bf9f47)
This commit is contained in:
parent
d80b00f320
commit
eb52d31ddf
@ -79,6 +79,7 @@
|
||||
#include <qtooltip.h>
|
||||
#include <qstyleoption.h>
|
||||
#include <QtWidgets/qlineedit.h>
|
||||
#include <QtGui/qaccessible.h>
|
||||
|
||||
#ifndef QT_NO_SHORTCUT
|
||||
#include "private/qapplication_p.h"
|
||||
@ -577,8 +578,15 @@ void QWidgetTextControlPrivate::repaintOldAndNewSelection(const QTextCursor &old
|
||||
void QWidgetTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged /*=false*/)
|
||||
{
|
||||
Q_Q(QWidgetTextControl);
|
||||
if (forceEmitSelectionChanged)
|
||||
if (forceEmitSelectionChanged) {
|
||||
emit q->selectionChanged();
|
||||
#ifndef QT_NO_ACCESSIBILITY
|
||||
if (q->parent()) {
|
||||
QAccessibleTextSelectionEvent ev(q->parent(), cursor.anchor(), cursor.position());
|
||||
QAccessible::updateAccessibility(&ev);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (cursor.position() == lastSelectionPosition
|
||||
&& cursor.anchor() == lastSelectionAnchor)
|
||||
@ -593,9 +601,15 @@ void QWidgetTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged
|
||||
&& (selectionStateChange
|
||||
|| (cursor.hasSelection()
|
||||
&& (cursor.position() != lastSelectionPosition
|
||||
|| cursor.anchor() != lastSelectionAnchor))))
|
||||
|| cursor.anchor() != lastSelectionAnchor)))) {
|
||||
emit q->selectionChanged();
|
||||
|
||||
#ifndef QT_NO_ACCESSIBILITY
|
||||
if (q->parent()) {
|
||||
QAccessibleTextSelectionEvent ev(q->parent(), cursor.anchor(), cursor.position());
|
||||
QAccessible::updateAccessibility(&ev);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
emit q->microFocusChanged();
|
||||
lastSelectionPosition = cursor.position();
|
||||
lastSelectionAnchor = cursor.anchor();
|
||||
|
@ -1590,6 +1590,22 @@ void tst_QAccessibility::textEditTest()
|
||||
iface->editableTextInterface()->cutText(12, 16);
|
||||
QCOMPARE(QApplication::clipboard()->text(), QLatin1String("how "));
|
||||
QCOMPARE(iface->textInterface()->text(12, 15), QLatin1String("are"));
|
||||
|
||||
QTestAccessibility::clearEvents();
|
||||
|
||||
// select text
|
||||
QTextCursor c = edit.textCursor();
|
||||
c.setPosition(2);
|
||||
c.setPosition(4, QTextCursor::KeepAnchor);
|
||||
edit.setTextCursor(c);
|
||||
QAccessibleTextSelectionEvent sel(&edit, 2, 4);
|
||||
QVERIFY_EVENT(&sel);
|
||||
|
||||
edit.selectAll();
|
||||
int end = edit.textCursor().position();
|
||||
sel.setCursorPosition(end);
|
||||
sel.setSelection(0, end);
|
||||
QVERIFY_EVENT(&sel);
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
}
|
||||
@ -1923,7 +1939,6 @@ void tst_QAccessibility::lineEditTest()
|
||||
QVERIFY_EVENT(&cursor);
|
||||
|
||||
lineEdit->setText("foo");
|
||||
qDebug() << QTestAccessibility::events();
|
||||
cursorEvent.setCursorPosition(3);
|
||||
QVERIFY_EVENT(&cursorEvent);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user