diff options
author | Richard Moe Gustavsen <richard.gustavsen@digia.com> | 2013-11-14 09:58:25 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-25 17:11:26 +0100 |
commit | 953d85e049786ddb5666d03b96da57fd546b9368 (patch) | |
tree | 9aa6766e3249e36b4b86ba391ece959c55717eed /src/plugins/platforms/ios/qioswindow.mm | |
parent | 344a7c540b76c11328fbe2592cf6e9f2b3d942c0 (diff) |
iOS: scroll screen when keyboard opens
This change will let QIOSInputContext scroll the root
view when the virtual keyboard is open, so that the input cursor
is not obscured.
Change-Id: If0758f4bf04c2b8e554e0196451154def7e3cb86
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'src/plugins/platforms/ios/qioswindow.mm')
-rw-r--r-- | src/plugins/platforms/ios/qioswindow.mm | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 8124d8ffb9..7030df5d32 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -181,11 +181,14 @@ QRect actualGeometry; if (m_qioswindow->window()->isTopLevel()) { UIWindow *uiWindow = self.window; + UIView *rootView = uiWindow.rootViewController.view; CGRect rootViewPositionInRelationToRootViewController = - [uiWindow.rootViewController.view convertRect:uiWindow.bounds fromView:uiWindow]; + [rootView convertRect:uiWindow.bounds fromView:uiWindow]; - actualGeometry = fromCGRect(CGRectOffset([self.superview convertRect:self.frame toView:uiWindow.rootViewController.view], - -rootViewPositionInRelationToRootViewController.origin.x, -rootViewPositionInRelationToRootViewController.origin.y)); + actualGeometry = fromCGRect(CGRectOffset([self.superview convertRect:self.frame toView:rootView], + -rootViewPositionInRelationToRootViewController.origin.x, + -rootViewPositionInRelationToRootViewController.origin.y + + rootView.bounds.origin.y)); } else { actualGeometry = fromCGRect(self.frame); } @@ -515,13 +518,17 @@ void QIOSWindow::applyGeometry(const QRect &rect) if (window()->isTopLevel()) { // The QWindow is in QScreen coordinates, which maps to a possibly rotated root-view-controller. // Since the root-view-controller might be translated in relation to the UIWindow, we need to - // check specifically for that and compensate. + // check specifically for that and compensate. Also check if the root view has been scrolled + // as a result of the keyboard being open. UIWindow *uiWindow = m_view.window; + UIView *rootView = uiWindow.rootViewController.view; CGRect rootViewPositionInRelationToRootViewController = - [uiWindow.rootViewController.view convertRect:uiWindow.bounds fromView:uiWindow]; + [rootView convertRect:uiWindow.bounds fromView:uiWindow]; - m_view.frame = CGRectOffset([m_view.superview convertRect:toCGRect(rect) fromView:m_view.window.rootViewController.view], - rootViewPositionInRelationToRootViewController.origin.x, rootViewPositionInRelationToRootViewController.origin.y); + m_view.frame = CGRectOffset([m_view.superview convertRect:toCGRect(rect) fromView:rootView], + rootViewPositionInRelationToRootViewController.origin.x, + rootViewPositionInRelationToRootViewController.origin.y + + rootView.bounds.origin.y); } else { // Easy, in parent's coordinates m_view.frame = toCGRect(rect); |