From 28f32afd3fed07c7772b76faf731bb104810d934 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 23 May 2014 10:51:19 +0200 Subject: iOS: Be more careful when hiding the keyboard upon enter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A typical pattern in an application is to listen for "enter" in a line edit and transfer focus to the next edit in the focus chain. This would currently not work on iOS since we would force the keyboard down after delivering the KeyPress/release events, effectively overriding any focus handling done by the app. This patch will hide the keyboard _before_ sending the events, so that we don't override focus handling done by the app. By also hiding the keyboard using QInputMethod, the hiding will also be delayed a bit (in QIOSInputContext) to catch subsequent hide/show calls. Change-Id: Ic19511d494a55d1bda963ed9bc7185d63b51bc03 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/quiview_textinput.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/quiview_textinput.mm b/src/plugins/platforms/ios/quiview_textinput.mm index 79e3897013..03006b3f99 100644 --- a/src/plugins/platforms/ios/quiview_textinput.mm +++ b/src/plugins/platforms/ios/quiview_textinput.mm @@ -495,14 +495,14 @@ Q_GLOBAL_STATIC(StaticVariables, staticVariables); return; if ([text isEqualToString:@"\n"]) { + if (self.returnKeyType == UIReturnKeyDone) + qApp->inputMethod()->hide(); + QKeyEvent press(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier); QKeyEvent release(QEvent::KeyRelease, Qt::Key_Return, Qt::NoModifier); [self sendEventToFocusObject:press]; [self sendEventToFocusObject:release]; - if (self.returnKeyType == UIReturnKeyDone) - [self resignFirstResponder]; - return; } -- cgit v1.2.3