summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-04-27 11:16:04 +1000
committerAndrew den Exter <andrew.den-exter@nokia.com>2011-04-27 11:34:05 +1000
commit10830210607d08eeb2af5d091639506a7d8cc634 (patch)
tree0b5c3d8bb44c5d13bf08e634a3b2e3f315dea96c
parentf14ac31c86eeb53d0b08c799ad0ad895d17475d6 (diff)
Move the TextInput cursor delegate when the preedit position changes.
Change-Id: Ia7150122444e465ffbcc02e921d42d01c2dfdac1 Task-number: QTBUG-18892 Reviewed-by: Martin Jones
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp6
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp9
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp9
3 files changed, 23 insertions, 1 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index ee241d614e..6eb6b68994 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 26a6fd8dae..53f8a24806 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 baaf862918..d4b844cd78 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()));