summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@theqtcompany.com>2015-08-03 12:59:01 +0200
committerRichard Moe Gustavsen <richard.gustavsen@theqtcompany.com>2015-09-01 08:58:41 +0000
commit21e1354d42d1bb3967dedb62facc684a8ab702ce (patch)
tree85d131115eaf3be01f8bb0c40f17e8a28fee3cb6 /src
parent97b525e3bee99d8c5bb6ae3819c82d5144c08f1d (diff)
iOS: handle all directions when calculating positionFromPosition
The method is currently a bit buggy, since it does not take UITextLayoutDirectionUp and UITextLayoutDirectionDown into account. This patch is mostly for fixing something "just in case", since we so far have not seen UIKit calling this method for those directions unless a hardware keyboard is connected. And in that case, we anyway override IM navigation by dealing with the arrow keys explicit. Since IM in Qt does not support getting the position above or below the current position, we just return the current position, making it a no-op. Change-Id: I4bcb9e2a00ab4e3d785058d7ff7f4855142dabbc Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.mm12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm
index 624411ebbc..685ff8ff47 100644
--- a/src/plugins/platforms/ios/qiostextresponder.mm
+++ b/src/plugins/platforms/ios/qiostextresponder.mm
@@ -652,7 +652,17 @@
- (UITextPosition *)positionFromPosition:(UITextPosition *)position inDirection:(UITextLayoutDirection)direction offset:(NSInteger)offset
{
int p = static_cast<QUITextPosition *>(position).index;
- return [QUITextPosition positionWithIndex:(direction == UITextLayoutDirectionRight ? p + offset : p - offset)];
+
+ switch (direction) {
+ case UITextLayoutDirectionLeft:
+ return [QUITextPosition positionWithIndex:p - offset];
+ case UITextLayoutDirectionRight:
+ return [QUITextPosition positionWithIndex:p + offset];
+ default:
+ // Qt doesn't support getting the position above or below the current position, so
+ // for those cases we just return the current position, making it a no-op.
+ return position;
+ }
}
- (UITextPosition *)positionWithinRange:(UITextRange *)range farthestInDirection:(UITextLayoutDirection)direction