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>
This commit is contained in:
parent
60fe9fb018
commit
35dc77f8db
@ -453,19 +453,16 @@ Q_GLOBAL_STATIC(StaticVariables, staticVariables);
|
|||||||
|
|
||||||
- (void)insertText:(NSString *)text
|
- (void)insertText:(NSString *)text
|
||||||
{
|
{
|
||||||
QString string = QString::fromUtf8([text UTF8String]);
|
QObject *focusObject = QGuiApplication::focusObject();
|
||||||
int key = 0;
|
if (!focusObject)
|
||||||
if ([text isEqualToString:@"\n"]) {
|
return;
|
||||||
key = (int)Qt::Key_Return;
|
|
||||||
if (self.returnKeyType == UIReturnKeyDone)
|
|
||||||
[self resignFirstResponder];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send key event to window system interface
|
if ([text isEqualToString:@"\n"] && self.returnKeyType == UIReturnKeyDone)
|
||||||
QWindowSystemInterface::handleKeyEvent(
|
[self resignFirstResponder];
|
||||||
0, QEvent::KeyPress, key, Qt::NoModifier, string, false, int(string.length()));
|
|
||||||
QWindowSystemInterface::handleKeyEvent(
|
QInputMethodEvent e;
|
||||||
0, QEvent::KeyRelease, key, Qt::NoModifier, string, false, int(string.length()));
|
e.setCommitString(QString::fromNSString(text));
|
||||||
|
[self sendEventToFocusObject:e];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)deleteBackward
|
- (void)deleteBackward
|
||||||
|
Loading…
Reference in New Issue
Block a user