summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2013-11-20 22:14:40 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-25 17:11:26 +0100
commit0bfc1c8647c0137de08c5f9b44b1c7be44a44c7d (patch)
treef1e69fd02b6e2ee1b89620908ecec80702361c20
parent953d85e049786ddb5666d03b96da57fd546b9368 (diff)
iOS: don't scroll after inputItem has moved
If the inputItem moves, it typically means that the user scrolls or flicks the focus item around. In that case we should avoid scrolling the screen, otherwise they will "cancel out" each other. Besides, when the user flicks, he takes control over the whereabouts on the screen anyway. Change-Id: Iad0762965f9dcdbcca934ce6d90a8c1413ce3ca2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.h3
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.mm13
2 files changed, 16 insertions, 0 deletions
diff --git a/src/plugins/platforms/ios/qiosinputcontext.h b/src/plugins/platforms/ios/qiosinputcontext.h
index 6ad2a808a6..3caadac29d 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.h
+++ b/src/plugins/platforms/ios/qiosinputcontext.h
@@ -44,6 +44,7 @@
#include <UIKit/UIKit.h>
+#include <QtGui/qtransform.h>
#include <qpa/qplatforminputcontext.h>
QT_BEGIN_NAMESPACE
@@ -60,6 +61,7 @@ public:
void showInputPanel();
void hideInputPanel();
bool isInputPanelVisible() const;
+ void setFocusObject(QObject *object);
void focusWindowChanged(QWindow *focusWindow);
void scrollRootView();
@@ -67,6 +69,7 @@ public:
private:
QIOSKeyboardListener *m_keyboardListener;
UIView<UIKeyInput> *m_focusView;
+ QTransform m_inputItemTransform;
bool m_hasPendingHideRequest;
};
diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm
index 7aee1f9bd6..547f405a01 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.mm
+++ b/src/plugins/platforms/ios/qiosinputcontext.mm
@@ -215,6 +215,12 @@ bool QIOSInputContext::isInputPanelVisible() const
return m_keyboardListener->m_keyboardVisible;
}
+void QIOSInputContext::setFocusObject(QObject *)
+{
+ m_inputItemTransform = qApp->inputMethod()->inputItemTransform();
+ scrollRootView();
+}
+
void QIOSInputContext::focusWindowChanged(QWindow *focusWindow)
{
UIView<UIKeyInput> *view = reinterpret_cast<UIView<UIKeyInput> *>(focusWindow->handle()->winId());
@@ -231,9 +237,16 @@ void QIOSInputContext::scrollRootView()
// - the focus object is on the same screen as the keyboard.
// - the first responder is a QUIView, and not some other foreign UIView.
// - the keyboard is docked. Otherwise the user can move the keyboard instead.
+ // - the inputItem has not been moved/scrolled
if (!isQtApplication() || !m_focusView)
return;
+ if (m_inputItemTransform != qApp->inputMethod()->inputItemTransform()) {
+ // The inputItem has moved since the last scroll update. To avoid competing
+ // with the application where the cursor/inputItem should be, we bail:
+ return;
+ }
+
UIView *view = m_keyboardListener->m_viewController.view;
qreal scrollTo = 0;