From a3b5947d3623ac3da4ee21056214835f1e5c06da Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 18 Jun 2013 11:03:16 +0200 Subject: iOS: activate window when input panel opens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a window is active in Qt, it means that is has keyboard focus. And on iOS, we only want a window to be rendered with keyboard focus when the input panel is open. Therefore we choose to call QWindowSystemInterface::handleWindowActivated() as a response to the input panel opening or closing, rather than from QPlatformWindow::requestActivateWindow(). And becoming or resigning first responder is that same as showing or hiding the input panel. Change-Id: I33b1bad769bec1fdd7c6ae4119b4b445da2f930f Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qioswindow.mm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/ios') diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 0c3ae8e834..4c8a16b0bc 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -247,6 +247,23 @@ return YES; } +- (BOOL)becomeFirstResponder +{ + // On iOS, a QWindow should only have input focus when the input panel is + // open. This is to stop cursors and focus rects from being drawn when the + // user cannot type. And since the keyboard will open when a view becomes + // the first responder, it's now a good time to inform QPA that the QWindow + // this view backs became active: + QWindowSystemInterface::handleWindowActivated(m_qioswindow->window()); + return [super becomeFirstResponder]; +} + +- (BOOL)resignFirstResponder +{ + QWindowSystemInterface::handleWindowActivated(0); + return [super resignFirstResponder]; +} + - (BOOL)hasText { return YES; @@ -416,7 +433,6 @@ void QIOSWindow::requestActivateWindow() raise(); QPlatformInputContext *context = QGuiApplicationPrivate::platformIntegration()->inputContext(); static_cast(context)->focusViewChanged(m_view); - QPlatformWindow::requestActivateWindow(); } void QIOSWindow::raiseOrLower(bool raise) -- cgit v1.2.3