summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qiosinputcontext.mm
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2014-02-25 15:27:09 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-15 10:45:31 +0100
commitde5185472651a6051a3c7b6e2519cc5f2b951a62 (patch)
tree8d113f4fdd3b0232e5f5311b8a4af5cec901f0f9 /src/plugins/platforms/ios/qiosinputcontext.mm
parent7b8d4cdb1098547ab2d2cc5337cae0496bb4ef61 (diff)
iOS: update keyboard rectangle when scrolling the screen
When we scroll, the keyboard will change position relative to QScreen, even if it appears to stay put. For that reason we also need to update the keyboard rect after doing a scroll. Change-Id: I9bda2ab5b5e4970f488d3e69e44cf58e273f8fcd Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'src/plugins/platforms/ios/qiosinputcontext.mm')
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.mm32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm
index 4fe2cae15e..fff7de8170 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.mm
+++ b/src/plugins/platforms/ios/qiosinputcontext.mm
@@ -131,16 +131,11 @@
- (void) keyboardDidChangeFrame:(NSNotification *)notification
{
+ Q_UNUSED(notification);
if (m_ignoreKeyboardChanges)
return;
- m_keyboardRect = [self getKeyboardRect:notification];
- m_context->emitKeyboardRectChanged();
- BOOL visible = m_keyboardRect.intersects(fromCGRect([UIScreen mainScreen].bounds));
- if (m_keyboardVisible != visible) {
- m_keyboardVisible = visible;
- m_context->emitInputPanelVisibleChanged();
- }
+ [self handleKeyboardRectChanged];
// If the keyboard was visible and docked from before, this is just a geometry
// change (normally caused by an orientation change). In that case, update scroll:
@@ -172,6 +167,22 @@
m_context->scroll(0);
}
+- (void) handleKeyboardRectChanged
+{
+ QRectF rect = m_keyboardEndRect;
+ rect.moveTop(rect.y() + m_viewController.view.bounds.origin.y);
+ if (m_keyboardRect != rect) {
+ m_keyboardRect = rect;
+ m_context->emitKeyboardRectChanged();
+ }
+
+ BOOL visible = m_keyboardEndRect.intersects(fromCGRect([UIScreen mainScreen].bounds));
+ if (m_keyboardVisible != visible) {
+ m_keyboardVisible = visible;
+ m_context->emitInputPanelVisibleChanged();
+ }
+}
+
@end
QIOSInputContext::QIOSInputContext()
@@ -295,10 +306,15 @@ void QIOSInputContext::scroll(int y)
CGRect newBounds = view.bounds;
newBounds.origin.y = y;
+ QPointer<QIOSInputContext> self = this;
[UIView animateWithDuration:m_keyboardListener->m_duration delay:0
options:m_keyboardListener->m_curve
animations:^{ view.bounds = newBounds; }
- completion:0];
+ completion:^(BOOL){
+ if (self)
+ [m_keyboardListener handleKeyboardRectChanged];
+ }
+ ];
}
void QIOSInputContext::update(Qt::InputMethodQueries query)