use of io.anuke.ucore.scene.ui.Dialog in project Mindustry by Anuken.
the class UI method showTextInput.
public void showTextInput(String title, String text, String def, TextFieldFilter filter, Consumer<String> confirmed) {
new Dialog(title, "dialog") {
{
content().margin(30).add(text).padRight(6f);
TextField field = content().addField(def, t -> {
}).size(170f, 50f).get();
field.setTextFieldFilter((f, c) -> field.getText().length() < 12 && filter.acceptChar(f, c));
Platform.instance.addDialog(field);
buttons().defaults().size(120, 54).pad(4);
buttons().addButton("$text.ok", () -> {
confirmed.accept(field.getText());
hide();
}).disabled(b -> field.getText().isEmpty());
buttons().addButton("$text.cancel", this::hide);
}
}.show();
}
Aggregations