mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-18 09:07:48 -04:00
Refactor TouchCharInput.java
This commit is contained in:
parent
ed68aca2a3
commit
22b45a1523
@ -36,7 +36,7 @@ public class TouchCharInput extends androidx.appcompat.widget.AppCompatEditText
|
||||
}
|
||||
|
||||
|
||||
private boolean isDoingInternalChanges = false;
|
||||
private boolean mIsDoingInternalChanges = false;
|
||||
|
||||
/**
|
||||
* We take the new chars, and send them to the game.
|
||||
@ -46,9 +46,9 @@ public class TouchCharInput extends androidx.appcompat.widget.AppCompatEditText
|
||||
@Override
|
||||
protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
|
||||
super.onTextChanged(text, start, lengthBefore, lengthAfter);
|
||||
if(isDoingInternalChanges)return;
|
||||
if(mIsDoingInternalChanges)return;
|
||||
|
||||
for(int i=0; i< lengthBefore; ++i){
|
||||
for(int i=0; i < lengthBefore; ++i){
|
||||
CallbackBridge.sendKeycode(LwjglGlfwKeycode.GLFW_KEY_BACKSPACE, '\u0008', 0, 0, true);
|
||||
}
|
||||
for(int i=start, count = 0; count < lengthAfter; ++i){
|
||||
@ -113,20 +113,12 @@ public class TouchCharInput extends androidx.appcompat.widget.AppCompatEditText
|
||||
*/
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void clear(){
|
||||
isDoingInternalChanges = true;
|
||||
mIsDoingInternalChanges = true;
|
||||
//Braille space, doesn't trigger keyboard auto-complete
|
||||
//replacing directly the text without though setText avoids notifying changes
|
||||
setText(" ");
|
||||
setSelection(getText().length());
|
||||
isDoingInternalChanges = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the enter key.
|
||||
*/
|
||||
private void sendEnter(){
|
||||
sendKeyPress(LwjglGlfwKeycode.GLFW_KEY_ENTER);
|
||||
clear();
|
||||
mIsDoingInternalChanges = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,6 +142,13 @@ public class TouchCharInput extends androidx.appcompat.widget.AppCompatEditText
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the enter key.
|
||||
*/
|
||||
private void sendEnter(){
|
||||
sendKeyPress(LwjglGlfwKeycode.GLFW_KEY_ENTER);
|
||||
clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function deals with anything that has to be executed when the constructor is called
|
||||
|
Loading…
x
Reference in New Issue
Block a user