iOS: Don't hide keyboard on "Done" button when focus object has changed

If the focus object changed programmatically for example to the next
input field in a window, we want to keep the keyboard open. This
strangely only worked if the inputs had different IM hints because this
made the keyboard appear again.

Change-Id: I52e66bb7d2ff97ae7084173769d9b5c2d0c549b5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
This commit is contained in:
Markus Goetz 2015-12-11 15:13:11 +01:00 committed by Simon Hausmann
parent bace82bffe
commit 8885344ad4

View File

@ -925,6 +925,14 @@
if ([text isEqualToString:@"\n"]) {
[self sendKeyPressRelease:Qt::Key_Return modifiers:Qt::NoModifier];
// An onEnter handler of a TextInput might move to the next input by calling
// nextInput.forceActiveFocus() which changes the focusObject.
// In that case we don't want to hide the VKB.
if (focusObject != QGuiApplication::focusObject()) {
qImDebug() << "focusObject already changed, not resigning first responder.";
return;
}
if (self.returnKeyType == UIReturnKeyDone || self.returnKeyType == UIReturnKeyGo
|| self.returnKeyType == UIReturnKeySend || self.returnKeyType == UIReturnKeySearch)
[self resignFirstResponder];