diff options
3 files changed, 23 insertions, 1 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index ee241d6..6eb6b68 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -949,6 +949,8 @@ void QDeclarativeTextInput::setCursorDelegate(QDeclarativeComponent* c) //note that the components are owned by something else disconnect(d->control, SIGNAL(cursorPositionChanged(int,int)), this, SLOT(moveCursor())); + disconnect(d->control, SIGNAL(updateMicroFocus()), + this, SLOT(moveCursor())); delete d->cursorItem; }else{ d->startCreatingCursor(); @@ -961,7 +963,9 @@ void QDeclarativeTextInputPrivate::startCreatingCursor() { Q_Q(QDeclarativeTextInput); q->connect(control, SIGNAL(cursorPositionChanged(int,int)), - q, SLOT(moveCursor())); + q, SLOT(moveCursor()), Qt::UniqueConnection); + q->connect(control, SIGNAL(updateMicroFocus()), + q, SLOT(moveCursor()), Qt::UniqueConnection); if(cursorComponent->isReady()){ q->createCursor(); }else if(cursorComponent->isLoading()){ diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 26a6fd8..53f8a24 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -1546,6 +1546,15 @@ void tst_qdeclarativetextedit::cursorDelegate() QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); } + const QString preedit = "preedit"; + for (int i = 0; i <= preedit.length(); i++) { + QInputMethodEvent event(preedit, QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, 1, QVariant())); + QApplication::sendEvent(view, &event); + + QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); + QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + } textEditObject->setCursorPosition(0); QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index baaf862..d4b844c 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -1643,6 +1643,15 @@ void tst_qdeclarativetextinput::cursorDelegate() QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x())); QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); } + const QString preedit = "preedit"; + for (int i = 0; i <= preedit.length(); i++) { + QInputMethodEvent event(preedit, QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, 1, QVariant())); + QApplication::sendEvent(view, &event); + + QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x())); + QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); + } textInputObject->setCursorPosition(0); QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x())); QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); |