add keyboard shortcut ctrl/cmd+alt+arrow to switch tabs

This commit is contained in:
Craig Raw 2023-10-24 15:06:21 +02:00
parent 158ecd4ab1
commit 1c9b6c3eef

View file

@ -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) {