Skip to content

Commit 4fa8d55

Browse files
committed
fix regression using ctrl-alt-n for new tab (fixes processing#2979)
1 parent 898a91d commit 4fa8d55

4 files changed

Lines changed: 19 additions & 15 deletions

File tree

app/src/processing/app/Editor.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,8 @@ public void actionPerformed(ActionEvent e) {
872872
menu.add(item);
873873

874874
// For Arduino and Mac, this should be command-E, but that currently conflicts with Export Applet
875-
item = Toolkit.newJMenuItemAlt(Language.text("menu.edit.use_selection_for_find"), 'F');
875+
//item = Toolkit.newJMenuItemAlt(Language.text("menu.edit.use_selection_for_find"), 'F');
876+
item = Toolkit.newJMenuItem(Language.text("menu.edit.use_selection_for_find"), 'E');
876877
item.addActionListener(new ActionListener() {
877878
public void actionPerformed(ActionEvent e) {
878879
if (find == null) {
@@ -882,19 +883,16 @@ public void actionPerformed(ActionEvent e) {
882883
}
883884
});
884885
menu.add(item);
885-
// Listener to the Edit menu item
886+
887+
// Update copy/cut state on selection/de-selection
886888
menu.addMenuListener(new MenuListener() {
887889

888890
@Override
889-
public void menuCanceled(MenuEvent e) {
890-
}
891+
public void menuCanceled(MenuEvent e) { }
891892

892893
@Override
893-
public void menuDeselected(MenuEvent e) {
894-
}
895-
/* Updating the copy and cut JMenuItems
896-
* as soon as the Edit menu is selected
897-
*/
894+
public void menuDeselected(MenuEvent e) { }
895+
898896
@Override
899897
public void menuSelected(MenuEvent e) {
900898
copyAction.updateCopyState();

app/src/processing/app/EditorHeader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ public void actionPerformed(ActionEvent e) {
520520
}
521521
};
522522
mapKey = "editor.header.new_tab";
523-
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.SHORTCUT_ALT_KEY_MASK);
523+
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.SHORTCUT_SHIFT_KEY_MASK);
524524
mInputMap.put(keyStroke, mapKey);
525525
mActionMap.put(mapKey, action);
526526
item.addActionListener(action);

app/src/processing/app/Toolkit.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,16 @@ public class Toolkit {
7676
/** Command on Mac OS X, Ctrl on Windows and Linux */
7777
static final int SHORTCUT_KEY_MASK =
7878
awtToolkit.getMenuShortcutKeyMask();
79+
7980
/** Command-W on Mac OS X, Ctrl-W on Windows and Linux */
8081
public static final KeyStroke WINDOW_CLOSE_KEYSTROKE =
81-
KeyStroke.getKeyStroke('W', SHORTCUT_KEY_MASK);
82+
KeyStroke.getKeyStroke('W', SHORTCUT_KEY_MASK);
8283
/** Command-Option on Mac OS X, Ctrl-Alt on Windows and Linux */
83-
static final int SHORTCUT_ALT_KEY_MASK = ActionEvent.ALT_MASK |
84-
awtToolkit.getMenuShortcutKeyMask();
84+
static final int SHORTCUT_ALT_KEY_MASK =
85+
ActionEvent.ALT_MASK | SHORTCUT_KEY_MASK;
86+
/** Command-Shift on Mac OS X, Ctrl-Shift on Windows and Linux */
87+
static final int SHORTCUT_SHIFT_KEY_MASK =
88+
ActionEvent.SHIFT_MASK | SHORTCUT_KEY_MASK;
8589

8690

8791
/**
@@ -112,7 +116,9 @@ static public JMenuItem newJMenuItemShift(String title, int what) {
112116

113117
/**
114118
* Same as newJMenuItem(), but adds the ALT (on Linux and Windows)
115-
* or OPTION (on Mac OS X) key as a modifier.
119+
* or OPTION (on Mac OS X) key as a modifier. This function should almost
120+
* never be used, because it's bad for non-US keyboards that use ALT in
121+
* strange and wondrous ways.
116122
*/
117123
static public JMenuItem newJMenuItemAlt(String title, int what) {
118124
JMenuItem menuItem = new JMenuItem(title);

app/src/processing/mode/java/JavaEditor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public Formatter createFormatter() {
5555
public JMenu buildFileMenu() {
5656
//String appTitle = JavaToolbar.getTitle(JavaToolbar.EXPORT, false);
5757
String appTitle = Language.text("toolbar.export_application");
58-
JMenuItem exportApplication = Toolkit.newJMenuItem(appTitle, 'E');
58+
JMenuItem exportApplication = Toolkit.newJMenuItemShift(appTitle, 'E');
5959
exportApplication.addActionListener(new ActionListener() {
6060
public void actionPerformed(ActionEvent e) {
6161
handleExportApplication();

0 commit comments

Comments
 (0)