mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2025-01-03 07:29:37 +01:00
Fixed bug 2265 - Voice to text feature on Android repeats some text via SDL_TEXTINPUT
Sylvain Small patch for this issue. I tested it and it seems to work. - it can send several backspaces (instead of only 1). - it calls directly "sendKeyEvent()" instead of "super.sendKeyEvent()". otherwise, it would go through the android internals, calling again "onKey()". and then the "backspace" would arrive after the next "commitText()".
This commit is contained in:
parent
5ca0152218
commit
6885bc88bf
@ -1683,10 +1683,16 @@ class SDLInputConnection extends BaseInputConnection {
|
|||||||
@Override
|
@Override
|
||||||
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
|
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
|
||||||
// Workaround to capture backspace key. Ref: http://stackoverflow.com/questions/14560344/android-backspace-in-webview-baseinputconnection
|
// Workaround to capture backspace key. Ref: http://stackoverflow.com/questions/14560344/android-backspace-in-webview-baseinputconnection
|
||||||
if (beforeLength == 1 && afterLength == 0) {
|
// and https://bugzilla.libsdl.org/show_bug.cgi?id=2265
|
||||||
// backspace
|
if (beforeLength > 0 && afterLength == 0) {
|
||||||
return super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL))
|
boolean ret = true;
|
||||||
&& super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DEL));
|
// backspace(s)
|
||||||
|
while (beforeLength-- > 0) {
|
||||||
|
boolean ret_key = sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL))
|
||||||
|
&& sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DEL));
|
||||||
|
ret = ret && ret_key;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.deleteSurroundingText(beforeLength, afterLength);
|
return super.deleteSurroundingText(beforeLength, afterLength);
|
||||||
|
Loading…
Reference in New Issue
Block a user