From e26587e807dd5f11e2e401ba65e40dc4e21717ee Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 11 Nov 2021 15:32:37 +0200 Subject: [PATCH] fix combobox texfield repeat selection --- .../sparrow/control/ComboBoxTextField.java | 14 ++++++++++++-- .../sparrowwallet/sparrow/io/ColdcardMultisig.java | 2 +- .../sparrow/io/ColdcardSinglesig.java | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/ComboBoxTextField.java b/src/main/java/com/sparrowwallet/sparrow/control/ComboBoxTextField.java index d37318cd..bf893986 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/ComboBoxTextField.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/ComboBoxTextField.java @@ -1,5 +1,6 @@ package com.sparrowwallet.sparrow.control; +import javafx.application.Platform; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.scene.Cursor; @@ -12,12 +13,13 @@ import org.controlsfx.control.textfield.CustomTextField; public class ComboBoxTextField extends CustomTextField { private final ObjectProperty> comboProperty = new SimpleObjectProperty<>(); + private boolean initialized; private boolean comboShowing; public ComboBoxTextField() { super(); getStyleClass().add("combo-text-field"); - setupCopyButtonField(super.rightProperty()); + setupComboButtonField(super.rightProperty()); disabledProperty().addListener((observable, oldValue, newValue) -> { if(comboProperty.isNotNull().get()) { @@ -26,7 +28,7 @@ public class ComboBoxTextField extends CustomTextField { }); } - private void setupCopyButtonField(ObjectProperty rightProperty) { + private void setupComboButtonField(ObjectProperty rightProperty) { Region showComboButton = new Region(); showComboButton.getStyleClass().addAll("graphic"); //$NON-NLS-1$ StackPane showComboButtonPane = new StackPane(showComboButton); @@ -41,6 +43,14 @@ public class ComboBoxTextField extends CustomTextField { } comboShowing = !comboShowing; + + if(!initialized) { + comboProperty.get().valueProperty().addListener((observable, oldValue, newValue) -> { + comboShowing = false; + Platform.runLater(() -> comboProperty.get().getSelectionModel().clearSelection()); + }); + initialized = true; + } } }); diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java index b1807c69..a3d56362 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java @@ -85,7 +85,7 @@ public class ColdcardMultisig implements WalletImport, KeystoreFileImport, Walle @Override public String getKeystoreImportDescription() { - return "Import file created by using the Settings > Multisig Wallets > Export XPUB feature on your Coldcard."; + return "Import file created by using the Settings > Multisig Wallets > Export XPUB > 0 feature on your Coldcard."; } @Override diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java index b614a440..50babc53 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java @@ -29,7 +29,7 @@ public class ColdcardSinglesig implements KeystoreFileImport, WalletImport { @Override public String getKeystoreImportDescription() { - return "Import file created by using the Advanced > MicroSD > Export Wallet > Generic JSON feature on your Coldcard. Note this requires firmware version 3.1.3 or later."; + return "Import file created by using the Advanced > MicroSD > Export Wallet > Generic JSON > 0 feature on your Coldcard. Note this requires firmware version 3.1.3 or later."; } @Override