From 1c9b6c3eef2a0b55e2c824650c7c1d75e19fa526 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 24 Oct 2023 15:06:21 +0200 Subject: [PATCH] add keyboard shortcut ctrl/cmd+alt+arrow to switch tabs --- .../com/sparrowwallet/sparrow/AppController.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index fc2af524..5f316daf 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -327,6 +327,8 @@ public class AppController implements Initializable { EventManager.get().post(new OpenWalletsEvent(tabs.getScene().getWindow(), Collections.emptyList())); }); + registerShortcuts(); + BitcoinUnit unit = Config.get().getBitcoinUnit(); if(unit == null) { unit = BitcoinUnit.AUTO; @@ -408,6 +410,19 @@ public class AppController implements Initializable { setNetworkLabel(); } + private void registerShortcuts() { + tabs.getScene().addEventFilter(KeyEvent.KEY_PRESSED, event -> { + if(event.isShortcutDown() && event.isAltDown()) { + int currentIndex = tabs.getSelectionModel().getSelectedIndex(); + if(event.getCode() == KeyCode.LEFT && currentIndex > 0) { + tabs.getSelectionModel().select(currentIndex - 1); + } else if(event.getCode() == KeyCode.RIGHT && currentIndex < tabs.getTabs().size() - 1) { + tabs.getSelectionModel().select(currentIndex + 1); + } + } + }); + } + private void setPlatformApplicationMenu() { org.controlsfx.tools.Platform platform = org.controlsfx.tools.Platform.getCurrent(); if(platform == org.controlsfx.tools.Platform.OSX) {