mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
add keyboard shortcut ctrl+pageup/pagedown to switch tabs on windows/linux
This commit is contained in:
parent
1c9b6c3eef
commit
ddae1a12d8
1 changed files with 23 additions and 9 deletions
|
@ -411,16 +411,30 @@ public class AppController implements Initializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerShortcuts() {
|
private void registerShortcuts() {
|
||||||
tabs.getScene().addEventFilter(KeyEvent.KEY_PRESSED, event -> {
|
org.controlsfx.tools.Platform platform = org.controlsfx.tools.Platform.getCurrent();
|
||||||
if(event.isShortcutDown() && event.isAltDown()) {
|
if(platform == org.controlsfx.tools.Platform.OSX) {
|
||||||
int currentIndex = tabs.getSelectionModel().getSelectedIndex();
|
tabs.getScene().addEventFilter(KeyEvent.KEY_PRESSED, event -> {
|
||||||
if(event.getCode() == KeyCode.LEFT && currentIndex > 0) {
|
if(event.isShortcutDown() && event.isAltDown()) {
|
||||||
tabs.getSelectionModel().select(currentIndex - 1);
|
int currentIndex = tabs.getSelectionModel().getSelectedIndex();
|
||||||
} else if(event.getCode() == KeyCode.RIGHT && currentIndex < tabs.getTabs().size() - 1) {
|
if(event.getCode() == KeyCode.LEFT && currentIndex > 0) {
|
||||||
tabs.getSelectionModel().select(currentIndex + 1);
|
tabs.getSelectionModel().select(currentIndex - 1);
|
||||||
|
} else if(event.getCode() == KeyCode.RIGHT && currentIndex < tabs.getTabs().size() - 1) {
|
||||||
|
tabs.getSelectionModel().select(currentIndex + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
} 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() {
|
||||||
|
|
Loading…
Reference in a new issue