mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-23 20:36:44 +00:00
Merge pull request #132 from haakonn/close-on-escape
Close "About" and "Introduction" when Escape key is pressed
This commit is contained in:
commit
8a77f22158
3 changed files with 14 additions and 2 deletions
|
@ -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"));
|
||||
|
|
Loading…
Reference in a new issue