diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2017-03-27 14:29:56 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2017-03-28 13:28:39 +0000 |
commit | 4b62d7ba9e0e38b5f8e3c66811b5e53da67f49a3 (patch) | |
tree | 2530a131b8393d861394287c002d867c5e365e7d /src/plugins/platforms/ios | |
parent | 239e862ff74429c6ae8edbaa204eeb4c3f5e89bf (diff) |
iOS: add support for using the input panel as a trackpad
With iOS 10 you can, with some versions of iPad/iPhone (e.g
iPad pro), start a trackpad gesture by using two finger swipe
on the input panel. This will let you move the cursor around
in the text edit.
This patch will implement the missing function that makes this
available also on Qt/iOS.
[ChangeLog][iOS] Support added for using the input panel as
a trackpad using two-finger swipe.
Task-number: QTBUG-59403
Change-Id: I456f5841e10d1e04218aafc78db87671f1a39ca9
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r-- | src/plugins/platforms/ios/qiostextresponder.mm | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index eab6792266..671e0f0c28 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -879,9 +879,10 @@ - (UITextPosition *)closestPositionToPoint:(CGPoint)point { - // No API in Qt for determining this. Use sensible default instead: - Q_UNUSED(point); - return [QUITextPosition positionWithIndex:[self currentImeState:Qt::ImCursorPosition].toInt()]; + QPointF p = QPointF::fromCGPoint(point); + const QTransform mapToLocal = QGuiApplication::inputMethod()->inputItemTransform().inverted(); + int textPos = QInputMethod::queryFocusObject(Qt::ImCursorPosition, p * mapToLocal).toInt(); + return [QUITextPosition positionWithIndex:textPos]; } - (UITextPosition *)closestPositionToPoint:(CGPoint)point withinRange:(UITextRange *)range |