v2.5.0: improved text input performance regarding copy/paste

This commit is contained in:
Evan Debenham
2024-08-29 15:03:08 -04:00
parent 3aab646840
commit cc3c434d35
2 changed files with 58 additions and 10 deletions

View File

@@ -76,7 +76,35 @@ public class TextInput extends Component {
TextField.TextFieldStyle style = skin.get(TextField.TextFieldStyle.class);
style.font = Game.platform.getFont(size, "", false, false);
style.background = null;
textField = multiline ? new TextArea("", style) : new TextField("", style);
if (multiline){
textField = new TextArea("", style){
@Override
public void cut() {
super.cut();
onClipBoardUpdate();
}
@Override
public void copy() {
super.copy();
onClipBoardUpdate();
}
};
} else {
textField = new TextField("", style){
@Override
public void cut() {
super.cut();
onClipBoardUpdate();
}
@Override
public void copy() {
super.copy();
onClipBoardUpdate();
}
};
}
textField.setProgrammaticChangeEvents(true);
if (!multiline) textField.setAlignment(Align.center);
@@ -90,6 +118,7 @@ public class TextInput extends Component {
style.font = f;
textField.setStyle(style);
}
onChanged();
}
});
@@ -117,9 +146,17 @@ public class TextInput extends Component {
}
public void enterPressed(){
//do nothing by default
//fires any time enter is pressed, do nothing by default
};
public void onChanged(){
//fires any time the text box is changed, do nothing by default
}
public void onClipBoardUpdate(){
//fires any time the clipboard is updated via cut or copy, do nothing by default
}
public void setText(String text){
textField.setText(text);
textField.setCursorPosition(textField.getText().length());