Browse Source
Merge pull request #132 from haakonn/close-on-escape
Close "About" and "Introduction" when Escape key is pressed
terminal
craigraw
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
14 additions and
2 deletions
-
src/main/java/com/sparrowwallet/sparrow/AppController.java
-
src/main/java/com/sparrowwallet/sparrow/AppServices.java
-
src/main/java/com/sparrowwallet/sparrow/WelcomeDialog.java
|
|
@ -351,7 +351,9 @@ public class AppController implements Initializable { |
|
|
|
stage.setTitle("About " + MainApp.APP_NAME); |
|
|
|
stage.initStyle(org.controlsfx.tools.Platform.getCurrent() == org.controlsfx.tools.Platform.OSX ? StageStyle.UNDECORATED : StageStyle.DECORATED); |
|
|
|
stage.setResizable(false); |
|
|
|
stage.setScene(new Scene(root)); |
|
|
|
Scene scene = new Scene(root); |
|
|
|
AppServices.onEscapePressed(scene, stage::close); |
|
|
|
stage.setScene(scene); |
|
|
|
controller.setStage(stage); |
|
|
|
controller.initializeView(); |
|
|
|
setStageIcon(stage); |
|
|
@ -1884,4 +1886,4 @@ public class AppController implements Initializable { |
|
|
|
public void recieveAction(ReceiveActionEvent event) { |
|
|
|
selectTab(event.getWallet()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
@ -31,6 +31,7 @@ import javafx.scene.control.Dialog; |
|
|
|
import javafx.scene.control.Label; |
|
|
|
import javafx.scene.image.Image; |
|
|
|
import javafx.scene.image.ImageView; |
|
|
|
import javafx.scene.input.KeyCode; |
|
|
|
import javafx.scene.text.Font; |
|
|
|
import javafx.stage.Screen; |
|
|
|
import javafx.stage.Stage; |
|
|
@ -449,6 +450,14 @@ public class AppServices { |
|
|
|
stage.hide(); |
|
|
|
} |
|
|
|
|
|
|
|
public static void onEscapePressed(Scene scene, Runnable runnable) { |
|
|
|
scene.setOnKeyPressed(event -> { |
|
|
|
if(event.getCode() == KeyCode.ESCAPE) { |
|
|
|
runnable.run(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public Map<Wallet, Storage> getOpenWallets() { |
|
|
|
Map<Wallet, Storage> openWallets = new LinkedHashMap<>(); |
|
|
|
for(List<WalletTabData> walletTabDataList : walletWindows.values()) { |
|
|
|
|
|
@ -12,6 +12,7 @@ public class WelcomeDialog extends Dialog<Mode> { |
|
|
|
public WelcomeDialog() { |
|
|
|
final DialogPane dialogPane = getDialogPane(); |
|
|
|
AppServices.setStageIcon(dialogPane.getScene().getWindow()); |
|
|
|
AppServices.onEscapePressed(dialogPane.getScene(), this::close); |
|
|
|
|
|
|
|
try { |
|
|
|
FXMLLoader welcomeLoader = new FXMLLoader(AppServices.class.getResource("welcome.fxml")); |
|
|
|