Android: Use proper empty strings in key events

A key event with no unicode would get a text of "\0" instead of
the empty string. This would lead to various widgets interpreting
the Key_Back event as text input, meaning that it would be grabbed
by the widget instead of being propagated.

Task-number: QTBUG-35784
Change-Id: Ibdb0e491572e41dd1aaf3b03ae1a780731f0559a
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
This commit is contained in:
Paul Olav Tvete 2014-03-12 15:34:49 +01:00 committed by The Qt Project
parent 1567699c0e
commit 80d4a19f51

View File

@ -517,6 +517,12 @@ namespace QtAndroidInput
}
}
// maps 0 to the empty string, and anything else to a single-character string
static inline QString toString(jint unicode)
{
return unicode ? QString(QChar(unicode)) : QString();
}
static void keyDown(JNIEnv */*env*/, jobject /*thiz*/, jint key, jint unicode, jint modifier)
{
Qt::KeyboardModifiers modifiers;
@ -533,7 +539,7 @@ namespace QtAndroidInput
QEvent::KeyPress,
mapAndroidKey(key),
modifiers,
QChar(unicode),
toString(unicode),
false);
}
@ -553,7 +559,7 @@ namespace QtAndroidInput
QEvent::KeyRelease,
mapAndroidKey(key),
modifiers,
QChar(unicode),
toString(unicode),
false);
}