add ctrl+shift+left/right keyboard shortcuts for moving tabs left and right
What changed, and why it matters
This commit adds keyboard shortcuts (Ctrl+Shift+Left/Right) to move wallet tabs left and right in the Sparrow Wallet application. It also slightly changes the underlying logic to use the currently selected tab rather than the tab that was right-clicked. There is no security issue visible in this change.
No security action required. This is a benign UI/UX enhancement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change registers two new accelerators on existing context-menu items for reordering tabs. The action handlers are refactored to operate on tabs.getSelectionModel().getSelectedItem() instead of the tab variable from the enclosing context. Bounds checks are added to prevent moving past the first or last tab. No input validation, cryptographic, network, or privilege-related code is involved.
Changed components
src/main/java/com/sparrowwallet/sparrow/AppController.javaInspect captured patch +18 / −8
diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java
index be7ae5a..7cbe477 100644
--- a/src/main/java/com/sparrowwallet/sparrow/AppController.java
+++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java
@@ -2096,23 +2096,33 @@ public class AppController implements Initializable {
}
MenuItem moveRight = new MenuItem("Move Right");
+ moveRight.setAccelerator(new KeyCodeCombination(KeyCode.RIGHT, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN));
moveRight.setOnAction(event -> {
- int index = tabs.getTabs().indexOf(tab);
+ int currentIndex = tabs.getSelectionModel().getSelectedIndex();
+ if(currentIndex + 1 >= tabs.getTabs().size()) {
+ return;
+ }
+ Tab selectedTab = tabs.getSelectionModel().getSelectedItem();
tabs.getTabs().removeListener(tabsChangeListener);
- tabs.getTabs().remove(tab);
- tabs.getTabs().add(index + 1, tab);
+ tabs.getTabs().remove(selectedTab);
+ tabs.getTabs().add(currentIndex + 1, selectedTab);
tabs.getTabs().addListener(tabsChangeListener);
- tabs.getSelectionModel().select(tab);
+ tabs.getSelectionModel().select(selectedTab);
EventManager.get().post(new RequestOpenWalletsEvent()); //Rearrange recent files list
});
MenuItem moveLeft = new MenuItem("Move Left");
+ moveLeft.setAccelerator(new KeyCodeCombination(KeyCode.LEFT, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN));
moveLeft.setOnAction(event -> {
- int index = tabs.getTabs().indexOf(tab);
+ int currentIndex = tabs.getSelectionModel().getSelectedIndex();
+ if(currentIndex == 0) {
+ return;
+ }
+ Tab selectedTab = tabs.getSelectionModel().getSelectedItem();
tabs.getTabs().removeListener(tabsChangeListener);
- tabs.getTabs().remove(tab);
- tabs.getTabs().add(index - 1, tab);
+ tabs.getTabs().remove(selectedTab);
+ tabs.getTabs().add(currentIndex - 1, selectedTab);
tabs.getTabs().addListener(tabsChangeListener);
- tabs.getSelectionModel().select(tab);
+ tabs.getSelectionModel().select(selectedTab);
EventManager.get().post(new RequestOpenWalletsEvent()); //Rearrange recent files list
});
contextMenu.getItems().addAll(moveRight, moveLeft);
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.