Skip to content

Commit 9fbf0b2

Browse files
authored
Improve command line shortcuts on Mac. (#10423)
On Mac, cmd-w is the standard shortcut for closing the window. So map it to "leave game". Change the shortcut for politics panel on Mac since cmd-w is not taken.
1 parent e63f274 commit 9fbf0b2

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/FileMenu.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ private void addExitMenu() {
100100
new JMenuItem(SwingAction.of("Leave Game", e -> frame.leaveGame()));
101101
leaveGameMenuExit.setMnemonic(KeyEvent.VK_L);
102102
if (isMac) { // On Mac OS X, the command-Q is reserved for the Quit action,
103-
// so set the command-L key combo for the Leave Game action
103+
// so set the command-W key combo for the Leave Game action
104104
leaveGameMenuExit.setAccelerator(
105105
KeyStroke.getKeyStroke(
106-
KeyEvent.VK_L, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()));
106+
KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()));
107107
} else { // On non-Mac operating systems, set the Ctrl-Q key combo for the Leave Game action
108108
leaveGameMenuExit.setAccelerator(
109109
KeyStroke.getKeyStroke(

game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/GameMenu.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ private void addPoliticsMenu() {
154154
frame, scroll, "Politics Panel", JOptionPane.PLAIN_MESSAGE);
155155
}));
156156
politicsMenuItem.setMnemonic(KeyEvent.VK_P);
157+
// On Mac, Cmd-W is the standard "close window" shortcut, which we use for "Leave Game".
158+
final int keyCode = (SystemProperties.isMac() ? KeyEvent.VK_P : KeyEvent.VK_W);
157159
politicsMenuItem.setAccelerator(
158-
KeyStroke.getKeyStroke(
159-
KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()));
160+
KeyStroke.getKeyStroke(keyCode, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()));
160161
}
161162

162163
private void addNotificationSettings() {

0 commit comments

Comments
 (0)