From ea2f858dc934352179c3f322553c524e0b6a8a91 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 28 Jun 2021 13:32:24 +0200 Subject: [PATCH] close message sign dialog on platform button and escape key --- .../sparrow/control/MessageSignDialog.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/MessageSignDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/MessageSignDialog.java index c00b329e..a535142f 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/MessageSignDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/MessageSignDialog.java @@ -51,6 +51,7 @@ public class MessageSignDialog extends Dialog { private final Wallet wallet; private WalletNode walletNode; private boolean electrumSignatureFormat; + private boolean closed; /** * Verification only constructor @@ -177,7 +178,7 @@ public class MessageSignDialog extends Dialog { ButtonType signButtonType = new javafx.scene.control.ButtonType("Sign", ButtonBar.ButtonData.BACK_PREVIOUS); ButtonType verifyButtonType = new javafx.scene.control.ButtonType("Verify", ButtonBar.ButtonData.NEXT_FORWARD); - ButtonType doneButtonType = new javafx.scene.control.ButtonType("Done", ButtonBar.ButtonData.OK_DONE); + ButtonType doneButtonType = new javafx.scene.control.ButtonType("Done", ButtonBar.ButtonData.CANCEL_CLOSE); if(buttons.length > 0) { dialogPane.getButtonTypes().addAll(buttons); @@ -189,7 +190,7 @@ public class MessageSignDialog extends Dialog { customSignButton.setOnAction(event -> { customSignButton.setDisable(true); signMessage(); - setResult(ButtonBar.ButtonData.OK_DONE); + setResult(ButtonBar.ButtonData.CANCEL_CLOSE); }); } } else { @@ -240,9 +241,13 @@ public class MessageSignDialog extends Dialog { return; } - EventManager.get().unregister(this); + if(!closed) { + EventManager.get().unregister(this); + closed = true; + } }); + AppServices.onEscapePressed(dialogPane.getScene(), () -> setResult(ButtonBar.ButtonData.CANCEL_CLOSE)); AppServices.moveToActiveWindowScreen(this); setResultConverter(dialogButton -> dialogButton == signButtonType || dialogButton == verifyButtonType ? ButtonBar.ButtonData.APPLY : dialogButton.getButtonData());