Reputation: 39
How to put some input mask like '999.999.999-99' on Gluon TextField. I could build a new component inheriting from JavaFX TextField but I'd rather use Gluon TextField because it fits best on mobile. I tried using StringConverter but it did not work.
Thanks!
Upvotes: 1
Views: 995
Reputation: 45476
The current Gluon Mobile TextFiled
control does support floating text, max length count, and other features, but doesn't allow a TextFormatter
directly.
If you have a look with ScenicView, the Gluon control is built upon a JavaFX TextField
control.
While a text formatter is added to the control, using a lookup
, you can get access to the internal JavaFX TextField
and apply it.
If you are using a View
created with FXML (Glisten-Afterburner template), that contains a Gluon Mobile TextField
, you could just get the JavaFX one:
@FXML
private TextField gluonTextField;
public void initialize() {
gluonTextField.setFloatText("Insert phone number");
primary.setOnShown(e -> {
javafx.scene.control.TextField javafxTextField = (javafx.scene.control.TextField) primary.lookup(".text-input");
if (javafxTextField != null) {
javafxTextField.setTextFormatter(new TextFormatter<>(...));
}
}
}
See this question for a possible implementation of a TextFormatter
for phone numbers.
Upvotes: 1