m_textLayout.setAdditionalFormats(formats);
updateDisplayText(/*force*/ true);
- if (cursorPositionChanged) {
- emitCursorPositionChanged();
- } else if (m_preeditCursor != oldPreeditCursor || isGettingInput) {
+ if ((cursorPositionChanged && !emitCursorPositionChanged())
+ || m_preeditCursor != oldPreeditCursor
+ || isGettingInput) {
q->updateCursorRectangle();
}
Rectangle { width: 300; height: 300; color: "white"
property string contextualProperty: "Hello"
TextEdit { text: "Hello world!"; id: textEditObject; objectName: "textEditObject"
+ width: 300; height: 300;
resources: [ Component { id:cursor; Item { id:cursorInstance; objectName: "cursorInstance"; property string localProperty: contextualProperty } } ]
cursorDelegate: cursor
}
text: "Hello world!"
id: textEditObject;
objectName: "textEditObject"
+ width: 300; height: 300
wrapMode: TextEdit.WordWrap
cursorDelegate: Cursor {
id:cursorInstance;
id: textEditObject
wrapMode: TextEdit.Wrap
objectName: "textEditObject"
+ width: 300; height: 300
cursorDelegate: Item {
id:cursorInstance
objectName: "cursorInstance"
QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
+ textEditObject->setReadOnly(false);
+
// Delegate moved when text is entered
textEditObject->setText(QString());
for (int i = 0; i < 20; ++i) {
for (int i = 0; i < 20; ++i) {
QInputMethodEvent event;
event.setCommitString("a");
- QGuiApplication::sendEvent(&view, &event);
+ QGuiApplication::sendEvent(textEditObject, &event);
+ QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
+ }
+ // Delegate moved when text is removed by im.
+ for (int i = 19; i > 1; --i) {
+ QInputMethodEvent event;
+ event.setCommitString(QString(), -1, 1);
+ QGuiApplication::sendEvent(textEditObject, &event);
+ QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
+ }
+ { // Delegate moved the text is changed in place by im.
+ QInputMethodEvent event;
+ event.setCommitString("i", -1, 1);
+ QGuiApplication::sendEvent(textEditObject, &event);
QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
}
Rectangle { id:rect; width: 300; height: 300; color: "white"
property string contextualProperty: "Hello"
TextInput { text: "Hello world!"; id: textInputObject; objectName: "textInputObject"
+ width: 300; height: 300
resources: [ Component { id:cursor; Item { id:cursorInstance; objectName: "cursorInstance"; property string localProperty: contextualProperty } } ]
cursorDelegate: cursor
}
text: "Hello world!"
id: textInputObject;
objectName: "textInputObject"
+ width: 300; height: 300
wrapMode: TextInput.Wrap
cursorDelegate: Cursor {
id:cursorInstance;
text: "Hello world!"
id: textInputObject
objectName: "textInputObject"
+ width: 300; height: 300
wrapMode: TextInput.WordWrap
cursorDelegate: Item {
id:cursorInstance
QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x());
QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y());
+ textInputObject->setReadOnly(false);
+
// Delegate moved when text is entered
textInputObject->setText(QString());
for (int i = 0; i < 20; ++i) {
textInputObject->setText(QString());
for (int i = 0; i < 20; ++i) {
QInputMethodEvent event;
- event.setCommitString("a");
- QGuiApplication::sendEvent(&view, &event);
+ event.setCommitString("w");
+ QGuiApplication::sendEvent(textInputObject, &event);
+ QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y());
+ }
+ // Delegate moved when text is removed by im.
+ for (int i = 19; i > 1; --i) {
+ QInputMethodEvent event;
+ event.setCommitString(QString(), -1, 1);
+ QGuiApplication::sendEvent(textInputObject, &event);
+ QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y());
+ }
+ { // Delegate moved the text is changed in place by im.
+ QInputMethodEvent event;
+ event.setCommitString("i", -1, 1);
+ QGuiApplication::sendEvent(textInputObject, &event);
QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x());
QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y());
}