diff options
author | Richard Moe Gustavsen <richard.gustavsen@digia.com> | 2014-11-07 23:52:20 +0100 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@theqtcompany.com> | 2014-11-13 20:03:09 +0100 |
commit | f12d4ee3fb6e647a0407c058ca76847ed3854a5e (patch) | |
tree | ab21886d29f68a64a82af2add6bdcc19e943693e /src/plugins/platforms/ios/qiosinputcontext.mm | |
parent | f3b93a7724929408a9b673674ffa73c164e0a771 (diff) |
iOS: close keyboard by resigning first responder
Current approach of reloading input views assumes that
the first responder is not a QIOSTextResponder, but
a QUIView. This is not always the case, e.g if someone
calls update after setting IM enabled on current focus
object to false. In that case we'll try to close the
keyboard by reloading input views on a quitextresponder which
can fail if the text responder has an external input view
attached.
This patch will instead hide the keyboard by resigning first
responder when it is a QIOSTextResponder. If it is not
a QIOSTextResponder it means that the keyboard is already
closed, or a third-party UIVIew that supports key input is first
responder. In either case we then leave it as-is.
Task-number: QTBUG-42523
Change-Id: I4dab648af9029941a8d5d3b00011fbd169be5482
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.mm | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm index 072a49c7c5..e417e9a1fb 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.mm +++ b/src/plugins/platforms/ios/qiosinputcontext.mm @@ -330,7 +330,6 @@ QIOSInputContext::QIOSInputContext() : QPlatformInputContext() , m_keyboardListener([[QIOSKeyboardListener alloc] initWithQIOSInputContext:this]) , m_textResponder(0) - , m_isReloadingInputViewsFromUpdate(false) { if (isQtApplication()) connect(qGuiApp->inputMethod(), &QInputMethod::cursorRectangleChanged, this, &QIOSInputContext::cursorRectangleChanged); @@ -540,10 +539,11 @@ void QIOSInputContext::update(Qt::InputMethodQueries updatedProperties) [m_textResponder autorelease]; m_textResponder = [[QIOSTextInputResponder alloc] initWithInputContext:this]; [m_textResponder becomeFirstResponder]; + } else if ([UIResponder currentFirstResponder] == m_textResponder) { + qImDebug() << "IM not enabled, resigning text responder as first responder"; + [m_textResponder resignFirstResponder]; } else { - qImDebug() << "IM not enabled, reloading input views"; - QScopedValueRollback<bool> recursionGuard(m_isReloadingInputViewsFromUpdate, true); - [[UIResponder currentFirstResponder] reloadInputViews]; + qImDebug() << "IM not enabled. Text responder not first responder. Nothing to do"; } } else { [m_textResponder notifyInputDelegate:changedProperties]; @@ -594,22 +594,3 @@ void QIOSInputContext::commit() [m_textResponder unmarkText]; [m_textResponder notifyInputDelegate:Qt::ImSurroundingText]; } - -// ------------------------------------------------------------------------- - -@interface QUIView (InputMethods) -- (void)reloadInputViews; -@end - -@implementation QUIView (InputMethods) -- (void)reloadInputViews -{ - if (QIOSInputContext::instance()->isReloadingInputViewsFromUpdate()) { - qImDebug() << "preventing recursion by reloading super"; - [super reloadInputViews]; - } else { - qImDebug() << "reseting input methods"; - qApp->inputMethod()->reset(); - } -} -@end |