From 4b62d7ba9e0e38b5f8e3c66811b5e53da67f49a3 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 27 Mar 2017 14:29:56 +0200 Subject: [PATCH] iOS: add support for using the input panel as a trackpad MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø --- src/plugins/platforms/ios/qiostextresponder.mm | 7 ++++--- 1 file 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