iOS: ensure that we restore text selection with correct cursor and anchor pos

Qt keeps track of the selection direction since a selection anchor can be placed
both to the left or to the right of the cursor. On iOS, the selection should
instead always be specified from left to right (using a position together with a
positive length). So when restoring the selection after performing the
calculation of the text rect, we need to ensure that we follow this format.

Change-Id: Id8bea6c35e2781e1431ee963f601b6e9ef05dbf5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
bb10
Richard Moe Gustavsen 2015-07-03 13:46:21 +02:00
parent 0cf00efced
commit afaeecd4e8
1 changed files with 1 additions and 1 deletions

View File

@ -578,7 +578,7 @@
if (cursorPos != int(r.location + r.length) || cursorPos != anchorPos) {
attrs = QList<QInputMethodEvent::Attribute>();
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, cursorPos, (cursorPos - anchorPos), 0);
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, qMin(cursorPos, anchorPos), qAbs(cursorPos - anchorPos), 0);
e = QInputMethodEvent(m_markedText, attrs);
[self sendEventToFocusObject:e];
}