QTextCursorPrivate *cursor_d = QTextCursorPrivate::getPrivate(&cursor);
if (cursor_d)
cursor_d->setX();
- q->updateCursorRectangle(oldPreeditCursor != preeditCursor || forceSelectionChanged);
+ q->updateCursorRectangle(oldPreeditCursor != preeditCursor || forceSelectionChanged || isGettingInput);
selectionChanged(forceSelectionChanged);
}
updateDisplayText(/*force*/ true);
if (cursorPositionChanged) {
emitCursorPositionChanged();
- } else if (m_preeditCursor != oldPreeditCursor) {
+ } else if (m_preeditCursor != oldPreeditCursor || isGettingInput) {
q->updateCursorRectangle();
}
emit q->selectionChanged();
}
- inputMethodAttributesChanged |= (m_cursor == m_lastCursorPos);
+ inputMethodAttributesChanged |= (m_cursor != m_lastCursorPos);
if (inputMethodAttributesChanged)
q->updateInputMethod();
emitUndoRedoChanged();
import QtQuick 2.0
TextEdit {
+ width: 300
focus: true
cursorDelegate: Item {
QCOMPARE(edit->cursorRectangle(), currentRect);
QCOMPARE(cursor->pos(), currentRect.topLeft());
QCOMPARE(currentRect, previousRect);
- QCOMPARE(editSpy.count(), 0); editSpy.clear();
- QCOMPARE(panelSpy.count(), 0); panelSpy.clear();
// Verify that the micro focus rect moves to the left as the cursor position
// is incremented.
+ editSpy.clear();
+ panelSpy.clear();
for (int i = 1; i <= 5; ++i) {
QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>()
<< QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, preeditText.length(), QVariant()));
previousRect = currentRect;
}
+ // Verify that if the cursor rectangle is updated if the pre-edit text changes
+ // but the (non-zero) cursor position is the same.
+ editSpy.clear();
+ panelSpy.clear();
+ { QInputMethodEvent imEvent("wwwww", QList<QInputMethodEvent::Attribute>()
+ << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 5, 1, QVariant()));
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); }
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ currentRect = query.value(Qt::ImCursorRectangle).toRectF();
+ QCOMPARE(edit->cursorRectangle(), currentRect);
+ QCOMPARE(cursor->pos(), currentRect.topLeft());
+ QCOMPARE(editSpy.count(), 1);
+ QCOMPARE(panelSpy.count(), 1);
+
// Verify that if there is no preedit cursor then the micro focus rect is the
// same as it would be if it were positioned at the end of the preedit text.
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
editSpy.clear();
panelSpy.clear();
{ QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>());
import QtQuick 2.0
TextInput {
+ width: 300
focus: true
autoScroll: false
previousRect = currentRect;
}
+ // Verify that if the cursor rectangle is updated if the pre-edit text changes
+ // but the (non-zero) cursor position is the same.
+ inputSpy.clear();
+ panelSpy.clear();
+ sendPreeditText("wwwww", 5);
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ currentRect = query.value(Qt::ImCursorRectangle).toRectF();
+ QCOMPARE(input->cursorRectangle(), currentRect);
+ QCOMPARE(cursor->pos(), currentRect.topLeft());
+ QCOMPARE(inputSpy.count(), 1);
+ QCOMPARE(panelSpy.count(), 1);
+
// Verify that if there is no preedit cursor then the micro focus rect is the
// same as it would be if it were positioned at the end of the preedit text.
- sendPreeditText(preeditText, 0);
- QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>());
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
+ inputSpy.clear();
+ panelSpy.clear();
+ { QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>());
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); }
QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
currentRect = query.value(Qt::ImCursorRectangle).toRectF();
QCOMPARE(currentRect, previousRect);
QCOMPARE(input->cursorRectangle(), currentRect);
QCOMPARE(cursor->pos(), currentRect.topLeft());
- QVERIFY(inputSpy.count() > 0);
- QVERIFY(panelSpy.count() > 0);
+ QCOMPARE(inputSpy.count(), 1);
+ QCOMPARE(panelSpy.count(), 1);
}
void tst_qquicktextinput::inputContextMouseHandler()