Android: Finish composing text before Key handling

If the sendKeyEvent was invoked, it means that the button not related
with composing text was used. In such case composing text (if it exists)
should be immediately finished.

Fixes: QTBUG-85715
Change-Id: Ifbca067805b8d20f6a90f95b27210595abed964a
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 0d5b43bed4d75ce4d1f1c5a7b953288f5570350d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Bartlomiej Moskal 2021-01-11 11:35:47 +01:00 committed by Qt Cherry-pick Bot
parent b5eb77a552
commit fe32ed6653

View File

@ -46,6 +46,7 @@ import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.ExtractedTextRequest;
import android.view.inputmethod.InputMethodManager;
import android.view.KeyEvent;
import android.graphics.Rect;
import android.app.Activity;
import android.util.DisplayMetrics;
@ -249,6 +250,16 @@ public class QtInputConnection extends BaseInputConnection
return super.performContextMenuAction(id);
}
@Override
public boolean sendKeyEvent(KeyEvent event)
{
// QTBUG-85715
// If the sendKeyEvent was invoked, it means that the button not related with composingText was used
// In such case composing text (if it exists) should be finished immediately
finishComposingText();
return super.sendKeyEvent(event);
}
@Override
public boolean setComposingText(CharSequence text, int newCursorPosition)
{