summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.h1
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.mm20
2 files changed, 19 insertions, 2 deletions
diff --git a/src/plugins/platforms/ios/qiosinputcontext.h b/src/plugins/platforms/ios/qiosinputcontext.h
index 3caadac29d..533ba686e1 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.h
+++ b/src/plugins/platforms/ios/qiosinputcontext.h
@@ -71,6 +71,7 @@ private:
UIView<UIKeyInput> *m_focusView;
QTransform m_inputItemTransform;
bool m_hasPendingHideRequest;
+ bool m_inSetFocusObject;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm
index 547f405a01..0e43429015 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.mm
+++ b/src/plugins/platforms/ios/qiosinputcontext.mm
@@ -170,6 +170,7 @@ QIOSInputContext::QIOSInputContext()
, m_keyboardListener([[QIOSKeyboardListener alloc] initWithQIOSInputContext:this])
, m_focusView(0)
, m_hasPendingHideRequest(false)
+ , m_inSetFocusObject(false)
{
if (isQtApplication())
connect(qGuiApp->inputMethod(), &QInputMethod::cursorRectangleChanged, this, &QIOSInputContext::scrollRootView);
@@ -218,7 +219,22 @@ bool QIOSInputContext::isInputPanelVisible() const
void QIOSInputContext::setFocusObject(QObject *)
{
m_inputItemTransform = qApp->inputMethod()->inputItemTransform();
- scrollRootView();
+
+ if (!m_focusView || !m_focusView.isFirstResponder)
+ return;
+
+ // Since m_focusView is the first responder, it means that the keyboard is open and we
+ // should update keyboard layout. But there seem to be no way to tell it to reread the
+ // UITextInputTraits from m_focusView. To work around that, we quickly resign first
+ // responder status just to reassign it again. To not remove the focusObject in the same
+ // go, we need to call the super implementation of resignFirstResponder. Since the call
+ // will cause a 'keyboardWillHide' notification to be sendt, we also block scrollRootView
+ // to avoid artifacts:
+ m_inSetFocusObject = true;
+ SEL sel = @selector(resignFirstResponder);
+ [[m_focusView superclass] instanceMethodForSelector:sel](m_focusView, sel);
+ m_inSetFocusObject = false;
+ [m_focusView becomeFirstResponder];
}
void QIOSInputContext::focusWindowChanged(QWindow *focusWindow)
@@ -238,7 +254,7 @@ void QIOSInputContext::scrollRootView()
// - 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)
+ if (!isQtApplication() || !m_focusView || m_inSetFocusObject)
return;
if (m_inputItemTransform != qApp->inputMethod()->inputItemTransform()) {