diff options
author | Richard Moe Gustavsen <richard.gustavsen@digia.com> | 2013-06-20 13:18:09 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-22 18:45:24 +0200 |
commit | ce16e70985384a8371cca65a5c3b8ec4c7563f5c (patch) | |
tree | 3d1c5c66006119d0fecec021d2f306035f82148e /src | |
parent | e4df7fc75ad16412b9fbe800b2d7a0b94bbfe8a7 (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/ios/qioswindow.mm | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 4c8a16b0bc..c8d0f823f6 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -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)]; |