diff options
author | Richard Moe Gustavsen <richard.gustavsen@digia.com> | 2013-06-18 11:03:16 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-06-25 15:10:50 +0200 |
commit | a3b5947d3623ac3da4ee21056214835f1e5c06da (patch) | |
tree | a69d8073c19a3e4bec2564926e978c76bd212db5 /src/plugins/platforms/ios | |
parent | 3b2ef66a988fc04ce070d74c5dafa4613821c6f6 (diff) |
iOS: activate window when input panel opens
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ø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r-- | src/plugins/platforms/ios/qioswindow.mm | 18 |
1 files changed, 17 insertions, 1 deletions
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<QIOSInputContext *>(context)->focusViewChanged(m_view); - QPlatformWindow::requestActivateWindow(); } void QIOSWindow::raiseOrLower(bool raise) |