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>
This commit is contained in:
Richard Moe Gustavsen 2013-06-18 11:03:16 +02:00 committed by The Qt Project
parent 3b2ef66a98
commit a3b5947d36

View File

@ -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)