iOS: send IM events instead of fake key events
Sending faked key events is not such a good idea, since:
1. We don't get key events on iOS, but text events
2. We cannot determine correct key code or modifiers, nor
do we want to fake modifer press/release etc.
3. Android uses IM for all text input
So it seems that the correct solution is to avoid sending
key events in the first place. This will also bring the iOS
port on par with the Android port.
Change-Id: Ibac1d335184e62eb4185cfd4218a0ec73dffb2c4
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
bb10
parent
60fe9fb018
commit
35dc77f8db
|
|
@ -453,19 +453,16 @@ Q_GLOBAL_STATIC(StaticVariables, staticVariables);
|
|||
|
||||
- (void)insertText:(NSString *)text
|
||||
{
|
||||
QString string = QString::fromUtf8([text UTF8String]);
|
||||
int key = 0;
|
||||
if ([text isEqualToString:@"\n"]) {
|
||||
key = (int)Qt::Key_Return;
|
||||
if (self.returnKeyType == UIReturnKeyDone)
|
||||
[self resignFirstResponder];
|
||||
}
|
||||
QObject *focusObject = QGuiApplication::focusObject();
|
||||
if (!focusObject)
|
||||
return;
|
||||
|
||||
// Send key event to window system interface
|
||||
QWindowSystemInterface::handleKeyEvent(
|
||||
0, QEvent::KeyPress, key, Qt::NoModifier, string, false, int(string.length()));
|
||||
QWindowSystemInterface::handleKeyEvent(
|
||||
0, QEvent::KeyRelease, key, Qt::NoModifier, string, false, int(string.length()));
|
||||
if ([text isEqualToString:@"\n"] && self.returnKeyType == UIReturnKeyDone)
|
||||
[self resignFirstResponder];
|
||||
|
||||
QInputMethodEvent e;
|
||||
e.setCommitString(QString::fromNSString(text));
|
||||
[self sendEventToFocusObject:e];
|
||||
}
|
||||
|
||||
- (void)deleteBackward
|
||||
|
|
|
|||
Loading…
Reference in New Issue