From e415ed83af3b90be76c63b21ee281eb48995c2ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 10 Dec 2014 16:45:45 +0100 Subject: iOS: Don't scroll screen on changes to input item transform MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We auto-scroll the screen to reveal the cursor whenever the cursor rect changes or other properties of the input methods are updated, but the expected behavior when explicitly moving an item under the keyboard, such as when scrolling a view or moving an item using drag, is to not scroll the screen until typing commences. This matches how eg. Safari or the Notes app handles the same use-case. Change-Id: I6b6932d9bcbdccd8df26db982246c162f1574d86 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosinputcontext.h | 1 - src/plugins/platforms/ios/qiosinputcontext.mm | 22 +++------------------- 2 files changed, 3 insertions(+), 20 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/ios/qiosinputcontext.h b/src/plugins/platforms/ios/qiosinputcontext.h index 863e503c3b..498db45ef2 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.h +++ b/src/plugins/platforms/ios/qiosinputcontext.h @@ -96,7 +96,6 @@ public: void setFocusObject(QObject *object) Q_DECL_OVERRIDE; void focusWindowChanged(QWindow *focusWindow); - void cursorRectangleChanged(); void scrollToCursor(); void scroll(int y); diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm index fe9ee18155..aebf8fff8f 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.mm +++ b/src/plugins/platforms/ios/qiosinputcontext.mm @@ -281,8 +281,6 @@ QIOSInputContext::QIOSInputContext() if (isQtApplication()) { QIOSScreen *iosScreen = static_cast(QGuiApplication::primaryScreen()->handle()); [iosScreen->uiWindow() addGestureRecognizer:m_keyboardHideGesture]; - - connect(qGuiApp->inputMethod(), &QInputMethod::cursorRectangleChanged, this, &QIOSInputContext::cursorRectangleChanged); } connect(qGuiApp, &QGuiApplication::focusWindowChanged, this, &QIOSInputContext::focusWindowChanged); @@ -400,23 +398,6 @@ QRectF QIOSInputContext::keyboardRect() const // ------------------------------------------------------------------------- -void QIOSInputContext::cursorRectangleChanged() -{ - if (!isInputPanelVisible() || !qApp->focusObject()) - return; - - // Check if the cursor has changed position inside the input item. Since - // qApp->inputMethod()->cursorRectangle() will also change when the input item - // itself moves, we need to ask the focus object for ImCursorRectangle: - static QPoint prevCursor; - QInputMethodQueryEvent queryEvent(Qt::ImCursorRectangle); - QCoreApplication::sendEvent(qApp->focusObject(), &queryEvent); - QPoint cursor = queryEvent.value(Qt::ImCursorRectangle).toRect().topLeft(); - if (cursor != prevCursor) - scrollToCursor(); - prevCursor = cursor; -} - UIView *QIOSInputContext::scrollableRootView() { if (!m_keyboardHideGesture.view) @@ -598,6 +579,9 @@ void QIOSInputContext::update(Qt::InputMethodQueries updatedProperties) } else { [m_textResponder notifyInputDelegate:changedProperties]; } + + if (changedProperties & Qt::ImCursorRectangle) + scrollToCursor(); } bool QIOSInputContext::inputMethodAccepted() const -- cgit v1.2.3