v1.0.1: pressing enter now confirms single line text input

This commit is contained in:
Evan Debenham
2021-08-24 21:59:00 -04:00
parent a3100b4fbb
commit b21e437011
2 changed files with 23 additions and 1 deletions

View File

@@ -71,11 +71,26 @@ public class TextInput extends Component {
}
}
});
if (!multiline){
textField.setTextFieldListener(new TextField.TextFieldListener(){
public void keyTyped (TextField textField, char c){
if (c == '\r' || c == '\n'){
enterPressed();
}
}
});
}
container.setActor(textField);
stage.setKeyboardFocus(textField);
Gdx.input.setOnscreenKeyboardVisible(true);
}
public void enterPressed(){
//do nothing by default
};
public void setText(String text){
textField.setText(text);
textField.setCursorPosition(textField.getText().length());