From 95517128d2b5ed6b3e993df3276c012199ec8ab9 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 5 Sep 2017 21:15:13 +0200 Subject: Update the cursor rectangle when select all is triggered MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When select all is triggered then the cursor rectangle should be updated to ensure that the selection handles are visible if they are displayed on a given platform. For instance, on iOS the loupe handles should appear in this case. This also has the added effect that when using Backspace on the iOS keyboard, it will delete the selected text as opposed to just a single character as it will handle that situation correctly. The tst_qquicktextedit::inputMethodUpdate() test is modified to account for the extra event sent now when selectAll() is called. Task-number: QTBUG-63835 Change-Id: I94fb0576b286c006dd12c65d0b322d712ed2a96f Reviewed-by: Tor Arne Vestbø --- src/quick/items/qquicktextcontrol.cpp | 3 +-- tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp index 2e23d69e5b..874c02fc99 100644 --- a/src/quick/items/qquicktextcontrol.cpp +++ b/src/quick/items/qquicktextcontrol.cpp @@ -432,6 +432,7 @@ void QQuickTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged / #endif emit q->selectionChanged(); } + q->updateCursorRectangle(true); } void QQuickTextControlPrivate::_q_updateCurrentCharFormatAndSelection() @@ -1150,7 +1151,6 @@ void QQuickTextControlPrivate::mouseMoveEvent(QMouseEvent *e, const QPointF &mou if (interactionFlags & Qt::TextEditable) { if (cursor.position() != oldCursorPos) { emit q->cursorPositionChanged(); - q->updateCursorRectangle(true); } _q_updateCurrentCharFormatAndSelection(); #if QT_CONFIG(im) @@ -1159,7 +1159,6 @@ void QQuickTextControlPrivate::mouseMoveEvent(QMouseEvent *e, const QPointF &mou #endif } else if (cursor.position() != oldCursorPos) { emit q->cursorPositionChanged(); - q->updateCursorRectangle(true); } selectionChanged(true); repaintOldAndNewSelection(oldSelection); diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index d58fc6c389..f4fef1f946 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -3205,7 +3205,7 @@ void tst_qquicktextedit::inputMethodUpdate() // programmatical selections trigger update platformInputContext.clear(); edit->selectAll(); - QCOMPARE(platformInputContext.m_updateCallCount, 1); + QVERIFY(platformInputContext.m_updateCallCount > 0); // font changes platformInputContext.clear(); -- cgit v1.2.3