diff options
author | Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com> | 2015-08-19 14:36:07 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com> | 2015-09-01 08:49:14 +0000 |
commit | 06be9f026f042f994d7c3548a331babca8d03545 (patch) | |
tree | 2eafddd737968aeffb8cb129cee288fc62572b7d /src/plugins/platforms/ios | |
parent | b4ed054e2f6b4c460f64c33b61b8800dc78f9e6d (diff) |
iOS: send key events through QPA
So far we have chosen to send key events directly to the focus
object since we do already do that for IM events. But Qt expects key
events (especially control keys) to be sendt through QPA.
This means that key events can end up somewhere else than at the focus
object, which is expected and needed if shortcut propagation is to
work.
Change-Id: I160bf3309572719eda352cdb11b46c4b5a455e0d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r-- | src/plugins/platforms/ios/qiostextresponder.mm | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index be9c3b9e27..68364d3c77 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -324,10 +324,8 @@ - (void)sendKeyPressRelease:(Qt::Key)key modifiers:(Qt::KeyboardModifiers)modifiers { - QKeyEvent press(QEvent::KeyPress, key, modifiers); - QKeyEvent release(QEvent::KeyRelease, key, modifiers); - [self sendEventToFocusObject:press]; - [self sendEventToFocusObject:release]; + QWindowSystemInterface::handleKeyEvent(qApp->focusWindow(), QEvent::KeyPress, key, modifiers); + QWindowSystemInterface::handleKeyEvent(qApp->focusWindow(), QEvent::KeyRelease, key, modifiers); } - (void)cut:(id)sender @@ -711,10 +709,10 @@ - (void)deleteBackward { - // Since we're posting im events directly to the focus object, we should do the - // same for key events. Otherwise they might end up in a different place or out - // of sync with im events. + // UITextInput selects the text to be deleted before calling this method. To avoid + // drawing the selection, we flush after posting the key press/release. [self sendKeyPressRelease:Qt::Key_Backspace modifiers:Qt::NoModifier]; + QWindowSystemInterface::flushWindowSystemEvents(); } @end |