From 8aa663e1393fcd2fa78eccc92b1acd7ba7c9cde2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 10 Dec 2014 16:44:48 +0100 Subject: iOS: Only scroll to cursor on keyboard hide gesture reset if requested MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I15b313b5f0d57358e405f16e941fc5061028c6a7 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosinputcontext.mm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm index aebf8fff8f..69bdf4aa87 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.mm +++ b/src/plugins/platforms/ios/qiosinputcontext.mm @@ -68,6 +68,7 @@ static QUIView *focusView() @private QIOSInputContext *m_context; } +@property BOOL hasDeferredScrollToCursor; @end @implementation QIOSKeyboardListener @@ -80,6 +81,8 @@ static QUIView *focusView() m_context = context; + self.hasDeferredScrollToCursor = NO; + // UIGestureRecognizer self.enabled = NO; self.cancelsTouchesInView = NO; @@ -231,9 +234,14 @@ static QUIView *focusView() qImDebug() << "keyboard was hidden, disabling hide-keyboard gesture"; self.enabled = NO; } else { - qImDebug() << "gesture completed without triggering, scrolling view to cursor"; - m_context->scrollToCursor(); + qImDebug() << "gesture completed without triggering"; + if (self.hasDeferredScrollToCursor) { + qImDebug() << "applying deferred scroll to cursor"; + m_context->scrollToCursor(); + } } + + self.hasDeferredScrollToCursor = NO; } @end @@ -418,7 +426,8 @@ void QIOSInputContext::scrollToCursor() if (m_keyboardHideGesture.state == UIGestureRecognizerStatePossible && m_keyboardHideGesture.numberOfTouches == 1) { // Don't scroll to the cursor if the user is touching the screen and possibly // trying to trigger the hide-keyboard gesture. - qImDebug() << "preventing scrolling to cursor as we're still waiting for a possible gesture"; + qImDebug() << "deferring scrolling to cursor as we're still waiting for a possible gesture"; + m_keyboardHideGesture.hasDeferredScrollToCursor = YES; return; } -- cgit v1.2.3