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>
bb10
Richard Moe Gustavsen 2017-03-27 14:29:56 +02:00
parent 239e862ff7
commit 4b62d7ba9e
1 changed files with 4 additions and 3 deletions

View File

@ -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