iOS: Only scroll to cursor on keyboard hide gesture reset if requested

Change-Id: I15b313b5f0d57358e405f16e941fc5061028c6a7
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
bb10
Tor Arne Vestbø 2014-12-10 16:44:48 +01:00 committed by Tor Arne Vestbø
parent e415ed83af
commit 8aa663e139
1 changed files with 12 additions and 3 deletions

View File

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