From 60e3d4e107dabfadf0ec73f72a74fdcff62ef4fd Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 4 Nov 2024 08:03:21 +0200 Subject: [PATCH] be more lenient in parsing pasted btc values to send tab textfields --- .../sparrow/control/CoinTextFormatter.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/CoinTextFormatter.java b/src/main/java/com/sparrowwallet/sparrow/control/CoinTextFormatter.java index 601d8f3b..ec38f8a1 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/CoinTextFormatter.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/CoinTextFormatter.java @@ -5,9 +5,9 @@ import javafx.scene.control.TextFormatter; import javafx.scene.control.TextInputControl; import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; import java.text.ParseException; import java.util.function.UnaryOperator; +import java.util.regex.Matcher; import java.util.regex.Pattern; public class CoinTextFormatter extends TextFormatter { @@ -51,8 +51,14 @@ public class CoinTextFormatter extends TextFormatter { commasRemoved = newText.length() - noFractionCommaText.length(); } - if(!coinValidation.matcher(noFractionCommaText).matches()) { - return null; + Matcher matcher = coinValidation.matcher(noFractionCommaText); + if(!matcher.matches()) { + matcher.reset(); + if(matcher.find()) { + noFractionCommaText = matcher.group(); + } else { + return null; + } } if(unitFormat.getGroupingSeparator().equals(change.getText())) {