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>bb10
parent
b4ed054e2f
commit
06be9f026f
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue