mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-11 13:45:48 -04:00
Feat[touch_char_input]: directly modify the Editable instead of relying on the internal TextView methods.
This commit is contained in:
parent
2a44e8da69
commit
5d8cf0d2dc
@ -3,9 +3,9 @@ package net.kdt.pojavlaunch.customcontrols.keyboard;
|
|||||||
|
|
||||||
import static android.content.Context.INPUT_METHOD_SERVICE;
|
import static android.content.Context.INPUT_METHOD_SERVICE;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
import android.text.Selection;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
@ -78,13 +78,15 @@ public class TouchCharInput extends androidx.appcompat.widget.AppCompatEditText
|
|||||||
* Clear the EditText from any leftover inputs
|
* Clear the EditText from any leftover inputs
|
||||||
* It does not affect the in-game input
|
* It does not affect the in-game input
|
||||||
*/
|
*/
|
||||||
@SuppressLint("SetTextI18n")
|
|
||||||
public void clear(){
|
public void clear(){
|
||||||
mIsDoingInternalChanges = true;
|
mIsDoingInternalChanges = true;
|
||||||
|
// Edit the Editable directly as it doesn't affect the state
|
||||||
|
// of the TextView.
|
||||||
|
Editable editable = getEditableText();
|
||||||
|
editable.clear();
|
||||||
//Braille space, doesn't trigger keyboard auto-complete
|
//Braille space, doesn't trigger keyboard auto-complete
|
||||||
//replacing directly the text without though setText avoids notifying changes
|
editable.append(TEXT_FILLER);
|
||||||
setText(TEXT_FILLER);
|
Selection.setSelection(editable, TEXT_FILLER.length());
|
||||||
setSelection(TEXT_FILLER.length());
|
|
||||||
mIsDoingInternalChanges = false;
|
mIsDoingInternalChanges = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user