Workaround for Google Keyboard strangeness

When deleting selected text, Google Keyboard will call
deleteSurroundingText() with a negative beforeLength. This does
not make any sense, and not all our controls are able to handle
the resulting input method events.

This patch interprets a negative beforeLength as a positive
afterLength. This works with the cases I have seen so far, but
since the keyboard is not following the specification, there
may be more weirdness later.

Task-number: QTBUG-46637
Change-Id: I410832417f6fb21139c338355e8fcfa57b9e544c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
bb10
Paul Olav Tvete 2015-06-15 10:54:56 +02:00
parent fb8b3e1bee
commit cef33870e4
1 changed files with 5 additions and 0 deletions

View File

@ -650,6 +650,11 @@ jboolean QAndroidInputContext::deleteSurroundingText(jint leftLength, jint right
m_composingText.clear();
m_composingTextStart = -1;
if (leftLength < 0) {
rightLength += -leftLength;
leftLength = 0;
}
QInputMethodEvent event;
event.setCommitString(QString(), -leftLength, leftLength+rightLength);
sendInputMethodEventThreadSafe(&event);