diff options
author | Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com> | 2015-03-11 15:43:43 +0100 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com> | 2015-03-12 13:07:35 +0000 |
commit | 4add7d236bbc3088a384f76de3a3df4668f8594b (patch) | |
tree | 97103035d3f6c600a81e7a855b0abe0b3f818f59 | |
parent | fe59121d24b25e23284e142e4a7d50ed4031627e (diff) |
iOS: ensure keyboard is visible, even when IM hints hasn't changed
When showing a QWindow, we transfer first responder status to its
QUIView. If another QWindow was active with a text responder at
that point, the text responder will loose first responder status
in favor of the new view, and the keyboard will hide.
Now, if the new window has a focus object with the same IM state
as the previous focus object (in the previous window), m_imeState
will not change, and QIOSIntegration::update() will assume that
nothing needs to be done to show the keyboard, even if it's
actually hidden.
This patch will change the logic, so that we:
- show the keyboard if its supposed to be visible, even if
m_imeState did not change.
- Only recreate the text responder if it needs a different
configuration than the one we already got (not only
from changes to Qt::ImEnabled)
Task-number: QTBUG-40695
Change-Id: I6f6788af4cbff5c7abe4f5a29e23a7cefea6b711
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
-rw-r--r-- | src/plugins/platforms/ios/qiosinputcontext.mm | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm index 22847b0612..a558ebe1f7 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.mm +++ b/src/plugins/platforms/ios/qiosinputcontext.mm @@ -587,28 +587,27 @@ void QIOSInputContext::update(Qt::InputMethodQueries updatedProperties) qImDebug() << "fw =" << qApp->focusWindow() << "fo =" << qApp->focusObject(); Qt::InputMethodQueries changedProperties = m_imeState.update(updatedProperties); - if (changedProperties & (Qt::ImEnabled | Qt::ImHints | Qt::ImPlatformData)) { - // Changes to enablement or hints require virtual keyboard reconfigure - - qImDebug() << "changed IM properties" << changedProperties << "require keyboard reconfigure"; + if (m_textResponder && changedProperties & (Qt::ImHints | Qt::ImPlatformData)) { + qImDebug() << "current IM state requires new text responder"; + [m_textResponder autorelease]; + m_textResponder = 0; + } - if (inputMethodAccepted()) { - qImDebug() << "replacing text responder with new text responder"; - [m_textResponder autorelease]; + if (inputMethodAccepted()) { + if (!m_textResponder) { + qImDebug() << "creating new text responder"; 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. Text responder not first responder. Nothing to do"; } - } else { + if (![m_textResponder isFirstResponder]) + [m_textResponder becomeFirstResponder]; + [m_textResponder notifyInputDelegate:changedProperties]; - } - if (changedProperties & Qt::ImCursorRectangle) - scrollToCursor(); + if (changedProperties & Qt::ImCursorRectangle) + scrollToCursor(); + } else if ([m_textResponder isFirstResponder]) { + [m_textResponder resignFirstResponder]; + } } bool QIOSInputContext::inputMethodAccepted() const |