iOS: Activate window on touchesEnded instead of touchesBegan

Since we await giving focus to a focus object until a press
release, it also makes sense to await activating a window until
a press release, since they both have to do with focus. By doing
so, the input panel now stays open if the user selects a line edit
in one window when a line edit in another window still has focus. We
also avoid activating a window in case of a touch cancel (e.g as
a result of the user flicking or triggering a gesture).

Change-Id: Ic00c4be69c257fceb10ce2d5a81cb490ea93710f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
bb10
Richard Moe Gustavsen 2013-06-20 13:18:09 +02:00 committed by The Qt Project
parent e4df7fc75a
commit ce16e70985
1 changed files with 8 additions and 6 deletions

View File

@ -183,12 +183,6 @@
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
QWindow *window = m_qioswindow->window();
// Transfer focus to the touched window:
if (window != QGuiApplication::focusWindow())
m_qioswindow->requestActivateWindow();
// UIKit generates [Began -> Moved -> Ended] event sequences for
// each touch point. Internally we keep a hashmap of active UITouch
// points to QWindowSystemInterface::TouchPoints, and assigns each TouchPoint
@ -210,6 +204,14 @@
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
QWindow *window = m_qioswindow->window();
if (window != QGuiApplication::focusWindow() && m_activeTouches.size() == 1) {
// Activate the touched window if the last touch was released inside it:
UITouch *touch = static_cast<UITouch *>([[touches allObjects] lastObject]);
if (CGRectContainsPoint([self bounds], [touch locationInView:self]))
m_qioswindow->requestActivateWindow();
}
[self updateTouchList:touches withState:Qt::TouchPointReleased];
[self sendTouchEventWithTimestamp:ulong(event.timestamp * 1000)];