add keyboard shortcut ctrl+pageup/pagedown to switch tabs on windows/linux

This commit is contained in:
Craig Raw 2023-10-24 15:34:20 +02:00
parent 1c9b6c3eef
commit ddae1a12d8

View file

@ -411,6 +411,8 @@ public class AppController implements Initializable {
} }
private void registerShortcuts() { private void registerShortcuts() {
org.controlsfx.tools.Platform platform = org.controlsfx.tools.Platform.getCurrent();
if(platform == org.controlsfx.tools.Platform.OSX) {
tabs.getScene().addEventFilter(KeyEvent.KEY_PRESSED, event -> { tabs.getScene().addEventFilter(KeyEvent.KEY_PRESSED, event -> {
if(event.isShortcutDown() && event.isAltDown()) { if(event.isShortcutDown() && event.isAltDown()) {
int currentIndex = tabs.getSelectionModel().getSelectedIndex(); int currentIndex = tabs.getSelectionModel().getSelectedIndex();
@ -421,6 +423,18 @@ public class AppController implements Initializable {
} }
} }
}); });
} else {
tabs.getScene().addEventFilter(KeyEvent.KEY_PRESSED, event -> {
if(event.isShortcutDown()) {
int currentIndex = tabs.getSelectionModel().getSelectedIndex();
if(event.getCode() == KeyCode.PAGE_UP && currentIndex > 0) {
tabs.getSelectionModel().select(currentIndex - 1);
} else if(event.getCode() == KeyCode.PAGE_DOWN && currentIndex < tabs.getTabs().size() - 1) {
tabs.getSelectionModel().select(currentIndex + 1);
}
}
});
}
} }
private void setPlatformApplicationMenu() { private void setPlatformApplicationMenu() {