trim leading and trailing whitespace from pay to address field

This commit is contained in:
Craig Raw 2023-05-25 16:15:38 +02:00
parent 3cf99961d3
commit 3aa00076c6

View file

@ -210,6 +210,18 @@ public class PaymentController extends WalletFormController implements Initializ
revalidateAmount();
});
address.setTextFormatter(new TextFormatter<>(change -> {
String controlNewText = change.getControlNewText();
if(!controlNewText.equals(controlNewText.trim())) {
String text = change.getText();
String newText = text.trim();
int caretPos = change.getCaretPosition() - text.length() + newText.length();
change.setText(newText);
change.selectRange(caretPos, caretPos);
}
return change;
}));
address.textProperty().addListener((observable, oldValue, newValue) -> {
address.leftProperty().set(null);