bool isGettingInput = !e->commitString().isEmpty()
|| e->preeditString() != cursor.block().layout()->preeditAreaText()
|| e->replacementLength() > 0;
+ bool forceSelectionChanged = false;
cursor.beginEditBlock();
if (isGettingInput) {
cursor.setPosition(blockStart + a.length, QTextCursor::KeepAnchor);
q->ensureCursorVisible();
repaintOldAndNewSelection(oldCursor);
+ forceSelectionChanged = true;
}
}
cursor.d->setX();
if (oldPreeditCursor != preeditCursor)
emit q->microFocusChanged();
+ selectionChanged(forceSelectionChanged);
}
QVariant QTextControl::inputMethodQuery(Qt::InputMethodQuery property) const
void bidiLogicalMovement_data();
void bidiLogicalMovement();
+ void inputMethodSelection();
+
private:
void createSelection();
int blockCount() const;
} while (moved && i >= 0);
}
+void tst_QTextEdit::inputMethodSelection()
+{
+ ed->setText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+
+ QSignalSpy selectionSpy(ed, SIGNAL(selectionChanged()));
+ QTextCursor cursor = ed->textCursor();
+ cursor.setPosition(0);
+ cursor.setPosition(5, QTextCursor::KeepAnchor);
+ ed->setTextCursor(cursor);
+
+ QCOMPARE(selectionSpy.count(), 1);
+ QCOMPARE(ed->textCursor().selectionStart(), 0);
+ QCOMPARE(ed->textCursor().selectionEnd(), 5);
+
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 12, 5, QVariant());
+ QInputMethodEvent event("", attributes);
+ QApplication::sendEvent(ed, &event);
+
+ QCOMPARE(selectionSpy.count(), 2);
+ QCOMPARE(ed->textCursor().selectionStart(), 12);
+ QCOMPARE(ed->textCursor().selectionEnd(), 17);
+}
+
+
QTEST_MAIN(tst_QTextEdit)
#include "tst_qtextedit.moc"