summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/widgets/qlinecontrol.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp18
2 files changed, 14 insertions, 6 deletions
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index 161ad04..9c2d354 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -664,6 +664,8 @@ bool QLineControl::finishChange(int validateFromState, bool update, bool edited)
m_selDirty = false;
emit selectionChanged();
}
+ if (m_cursor == m_lastCursorPos)
+ updateMicroFocus();
emitCursorPositionChanged();
return true;
}
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index 5305ed0..4466d9e 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -2536,13 +2536,15 @@ void tst_qdeclarativetextinput::preeditAutoScroll()
ic.sendPreeditText(preeditText.mid(0, 3), 1);
QVERIFY(input.positionAt(0) != 0);
QVERIFY(input.cursorRectangle().left() < input.boundingRect().width());
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QVERIFY(cursorRectangleSpy.count() > cursorRectangleChanges);
+ cursorRectangleChanges = cursorRectangleSpy.count();
// test the text is scrolled back when the preedit is removed.
ic.sendEvent(QInputMethodEvent());
QCOMPARE(input.positionAt(0), 0);
QCOMPARE(input.positionAt(input.width()), 5);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QVERIFY(cursorRectangleSpy.count() > cursorRectangleChanges);
+ cursorRectangleChanges = cursorRectangleSpy.count();
// some tolerance for different fonts.
#ifdef Q_OS_LINUX
@@ -2558,14 +2560,16 @@ void tst_qdeclarativetextinput::preeditAutoScroll()
ic.sendPreeditText(preeditText, i + 1);
QVERIFY(input.cursorRectangle().right() >= fm.width(preeditText.at(i)) - error);
QVERIFY(input.positionToRectangle(0).x() < x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QVERIFY(cursorRectangleSpy.count() > cursorRectangleChanges);
+ cursorRectangleChanges = cursorRectangleSpy.count();
x = input.positionToRectangle(0).x();
}
for (int i = 1; i >= 0; --i) {
ic.sendPreeditText(preeditText, i + 1);
QVERIFY(input.cursorRectangle().right() >= fm.width(preeditText.at(i)) - error);
QVERIFY(input.positionToRectangle(0).x() > x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QVERIFY(cursorRectangleSpy.count() > cursorRectangleChanges);
+ cursorRectangleChanges = cursorRectangleSpy.count();
x = input.positionToRectangle(0).x();
}
@@ -2577,12 +2581,14 @@ void tst_qdeclarativetextinput::preeditAutoScroll()
for (int i = 2; i >= 0; --i) {
ic.sendPreeditText(preeditText, preeditText.length() - i);
QCOMPARE(input.positionToRectangle(0).x(), x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QVERIFY(cursorRectangleSpy.count() > cursorRectangleChanges);
+ cursorRectangleChanges = cursorRectangleSpy.count();
}
for (int i = 1; i < 3; ++i) {
ic.sendPreeditText(preeditText, preeditText.length() - i);
QCOMPARE(input.positionToRectangle(0).x(), x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QVERIFY(cursorRectangleSpy.count() > cursorRectangleChanges);
+ cursorRectangleChanges = cursorRectangleSpy.count();
}
// Test disabling auto scroll.