summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qiosinputcontext.mm
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2014-03-20 10:52:10 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-29 10:39:11 +0100
commit8cde2faebccbea15c7e0c4df31402e6d3ce6a23f (patch)
tree1c663d1080d4840cbadc3747d948c16abf9f7e42 /src/plugins/platforms/ios/qiosinputcontext.mm
parent46acfa5d2ab803d8b5fbfbcdd826650b94624187 (diff)
iOS: don't scroll towards cursor during touch press
While the user is touching the screen, postpone scrolling until we get a touch release. Scrolling in the middle of a touch sequence will change the coordinates under the touch, and cause some artefacts. Change-Id: I02ef420abaab780a459f014d4b4cfb75c8fbb725 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src/plugins/platforms/ios/qiosinputcontext.mm')
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.mm19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm
index ab4e3f38e7..9a2c55f7f2 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.mm
+++ b/src/plugins/platforms/ios/qiosinputcontext.mm
@@ -55,6 +55,7 @@
BOOL m_keyboardVisible;
BOOL m_keyboardVisibleAndDocked;
BOOL m_ignoreKeyboardChanges;
+ BOOL m_touchPressWhileKeyboardVisible;
BOOL m_keyboardHiddenByGesture;
QRectF m_keyboardRect;
QRectF m_keyboardEndRect;
@@ -74,6 +75,7 @@
m_keyboardVisible = NO;
m_keyboardVisibleAndDocked = NO;
m_ignoreKeyboardChanges = NO;
+ m_touchPressWhileKeyboardVisible = NO;
m_keyboardHiddenByGesture = NO;
m_duration = 0;
m_curve = UIViewAnimationCurveEaseOut;
@@ -213,8 +215,16 @@
[super touchesMoved:touches withEvent:event];
}
+- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
+{
+ Q_ASSERT(m_keyboardVisibleAndDocked);
+ m_touchPressWhileKeyboardVisible = YES;
+ [super touchesBegan:touches withEvent:event];
+}
+
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
+ m_touchPressWhileKeyboardVisible = NO;
[self performSelectorOnMainThread:@selector(touchesEndedPostDelivery) withObject:nil waitUntilDone:NO];
[super touchesEnded:touches withEvent:event];
}
@@ -231,6 +241,8 @@
// the gesture, so we clear focus once more as a work-around.
static_cast<QWindowPrivate *>(QObjectPrivate::get(qApp->focusWindow()))->clearFocusObject();
}
+ } else {
+ m_context->scrollToCursor();
}
}
@@ -339,6 +351,13 @@ void QIOSInputContext::scrollToCursor()
if (!isQtApplication() || !m_focusView)
return;
+ if (m_keyboardListener->m_touchPressWhileKeyboardVisible) {
+ // Don't scroll to the cursor if the user is touching the screen. This
+ // interferes with selection and the 'hide keyboard' gesture. Instead
+ // we update scrolling upon touchEnd.
+ return;
+ }
+
UIView *view = m_keyboardListener->m_viewController.view;
if (view.window != m_focusView.window)
return;