summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2014-05-20 12:51:37 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-21 01:34:38 +0200
commitbf50bf737b6198a64756ce96ff9852c36e6f3066 (patch)
tree812134b46491ca7974d1360b596a21633b329631 /src
parent5283a6c87beac5a43f612786fefd6e43f2c70bf6 (diff)
iOS: don't report negative selection ranges for backspace
Qt sometimes report that the selection anchor is placed before the cursor when querying it for current selection. We need to accomodate for this when reporting current selection back to iOS, since it expects the range to always be positive. When pressing backspace, iOS will select the letter that should be deleted, and then call "deleteBackwards". If holding down backspace for a while, it will start selecting whole words instead. Since we reported negative ranges during this process, it caused artifacts and stray letters to be drawn. Task-number: QTBUG-39073 Change-Id: Ida9518307adce915adf49160b541a2f88637a0da Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/ios/quiview_textinput.mm2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/plugins/platforms/ios/quiview_textinput.mm b/src/plugins/platforms/ios/quiview_textinput.mm
index 3f6c6d1256..79e3897013 100644
--- a/src/plugins/platforms/ios/quiview_textinput.mm
+++ b/src/plugins/platforms/ios/quiview_textinput.mm
@@ -253,7 +253,7 @@ Q_GLOBAL_STATIC(StaticVariables, staticVariables);
- (UITextRange *)selectedTextRange {
int cursorPos = [self imValue:Qt::ImCursorPosition].toInt();
int anchorPos = [self imValue:Qt::ImAnchorPosition].toInt();
- return [QUITextRange rangeWithNSRange:NSMakeRange(cursorPos, (anchorPos - cursorPos))];
+ return [QUITextRange rangeWithNSRange:NSMakeRange(qMin(cursorPos, anchorPos), qAbs(anchorPos - cursorPos))];
}
- (NSString *)textInRange:(UITextRange *)range