v2.5.0: improved text input performance regarding copy/paste
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user