mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2026-08-09 16:24:53 +00:00
trim leading and trailing whitespace from pay to address field
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user