Skip to content

Commit 438dbb2

Browse files
committed
move problematic shortcuts out to the language files (fixes processing#2199)
1 parent 773b094 commit 438dbb2

File tree

6 files changed

+96
-35
lines changed

6 files changed

+96
-35
lines changed

app/src/processing/app/ui/Editor.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -956,23 +956,27 @@ public void actionPerformed(ActionEvent e) {
956956
});
957957
menu.add(item);
958958

959-
item = Toolkit.newJMenuItem(Language.text("menu.edit.comment_uncomment"), '/');
959+
item = Toolkit.newJMenuItem(Language.text("menu.edit.comment_uncomment"),
960+
Language.text("menu.edit.comment_uncomment.keystroke"));
960961
item.addActionListener(new ActionListener() {
961962
public void actionPerformed(ActionEvent e) {
962963
handleCommentUncomment();
963964
}
964965
});
965966
menu.add(item);
966967

967-
item = Toolkit.newJMenuItem("\u2192 "+Language.text("menu.edit.increase_indent"), ']');
968+
item = Toolkit.newJMenuItem("\u2192 " + Language.text("menu.edit.increase_indent"),
969+
Language.text("menu.edit.increase_indent.keystroke"));
970+
968971
item.addActionListener(new ActionListener() {
969972
public void actionPerformed(ActionEvent e) {
970973
handleIndentOutdent(true);
971974
}
972975
});
973976
menu.add(item);
974977

975-
item = Toolkit.newJMenuItem("\u2190 "+Language.text("menu.edit.decrease_indent"), '[');
978+
item = Toolkit.newJMenuItem("\u2190 " + Language.text("menu.edit.decrease_indent"),
979+
Language.text("menu.edit.decrease_indent.keystroke"));
976980
item.addActionListener(new ActionListener() {
977981
public void actionPerformed(ActionEvent e) {
978982
handleIndentOutdent(false);

app/src/processing/app/ui/EditorHeader.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,8 @@ public void actionPerformed(ActionEvent e) {
498498
if (Platform.isLinux()) {
499499
item = Toolkit.newJMenuItem(prevTab, KeyEvent.VK_PAGE_UP);
500500
} else {
501-
item = Toolkit.newJMenuItemAlt(prevTab, KeyEvent.VK_LEFT);
501+
//item = Toolkit.newJMenuItemAlt(prevTab, KeyEvent.VK_LEFT);
502+
item = Toolkit.newJMenuItem(prevTab, Language.text("editor.header.previous_tab.keystroke"));
502503
}
503504
action = new AbstractAction() {
504505
@Override
@@ -510,7 +511,8 @@ public void actionPerformed(ActionEvent e) {
510511
if (Platform.isLinux()) {
511512
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, Toolkit.SHORTCUT_KEY_MASK);
512513
} else {
513-
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Toolkit.SHORTCUT_ALT_KEY_MASK);
514+
//keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Toolkit.SHORTCUT_ALT_KEY_MASK);
515+
keyStroke = KeyStroke.getKeyStroke(Language.text("editor.header.previous_tab.keystroke"));
514516
}
515517
inputMap.put(keyStroke, mapKey);
516518
actionMap.put(mapKey, action);
@@ -521,7 +523,8 @@ public void actionPerformed(ActionEvent e) {
521523
if (Platform.isLinux()) {
522524
item = Toolkit.newJMenuItem(nextTab, KeyEvent.VK_PAGE_DOWN);
523525
} else {
524-
item = Toolkit.newJMenuItemAlt(nextTab, KeyEvent.VK_RIGHT);
526+
//item = Toolkit.newJMenuItemAlt(nextTab, KeyEvent.VK_RIGHT);
527+
item = Toolkit.newJMenuItem(nextTab, Language.text("editor.header.next_tab.keystroke"));
525528
}
526529
action = new AbstractAction() {
527530
@Override
@@ -533,7 +536,8 @@ public void actionPerformed(ActionEvent e) {
533536
if (Platform.isLinux()) {
534537
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, Toolkit.SHORTCUT_KEY_MASK);
535538
} else {
536-
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Toolkit.SHORTCUT_ALT_KEY_MASK);
539+
//keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Toolkit.SHORTCUT_ALT_KEY_MASK);
540+
keyStroke = KeyStroke.getKeyStroke(Language.text("editor.header.next_tab.keystroke"));
537541
}
538542
inputMap.put(keyStroke, mapKey);
539543
actionMap.put(mapKey, action);

app/src/processing/app/ui/Toolkit.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,29 @@ static public JMenuItem newJMenuItem(String title, int what) {
131131
}
132132

133133

134+
/**
135+
* Create a menu item and set its KeyStroke by name (so it can be stored
136+
* in the language settings or the preferences. Syntax is here:
137+
* https://docs.oracle.com/javase/8/docs/api/javax/swing/KeyStroke.html#getKeyStroke-java.lang.String-
138+
* @param sequence the name, as outlined by the KeyStroke API
139+
* @param fallback what to use if getKeyStroke() comes back null
140+
*/
141+
static public JMenuItem newJMenuItem(String title,
142+
String sequence) {
143+
JMenuItem menuItem = new JMenuItem(title);
144+
KeyStroke ks = KeyStroke.getKeyStroke(sequence);
145+
if (ks != null) {
146+
menuItem.setAccelerator(ks);
147+
148+
} else {
149+
System.err.println("'" + sequence + "' is not understood, " +
150+
"pleae re-read the Java reference for KeyStroke");
151+
//ks = KeyStroke.getKeyStroke(fallback);
152+
}
153+
return menuItem;
154+
}
155+
156+
134157
/**
135158
* @param action: use an Action, which sets the title, reaction
136159
* and enabled-ness all by itself.

build/shared/lib/languages/PDE.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ menu.edit.paste = Paste
4040
menu.edit.select_all = Select All
4141
menu.edit.auto_format = Auto Format
4242
menu.edit.comment_uncomment = Comment/Uncomment
43+
menu.edit.comment_uncomment.keystroke = meta pressed SLASH
4344
menu.edit.increase_indent = Increase Indent
45+
menu.edit.increase_indent.keystroke = meta pressed CLOSE_BRACKET
4446
menu.edit.decrease_indent = Decrease Indent
47+
menu.edit.decrease_indent.keystroke = meta pressed OPEN_BRACKET
4548
menu.edit.find = Find...
4649
menu.edit.find_next = Find Next
4750
menu.edit.find_previous = Find Previous
@@ -77,8 +80,11 @@ menu.debug.toggle_breakpoint = Toggle Breakpoint
7780
# ---
7881
# used for both menus and toolbars
7982
menu.debug.step = Step
83+
menu.debug.step.keystroke = meta pressed J
8084
menu.debug.step_into = Step Into
85+
menu.debug.step.keystroke = shift meta pressed J
8186
menu.debug.step_out = Step Out
87+
menu.debug.step.keystroke = meta alt pressed J
8288
menu.debug.continue = Continue
8389
# ---
8490
#menu.debug.print_stack_trace = Print Stack Trace

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,8 @@ public void actionPerformed(ActionEvent e) {
13841384
// });
13851385
// debugMenu.add(item);
13861386

1387-
item = Toolkit.newJMenuItem(Language.text("menu.debug.step"), KeyEvent.VK_J);
1387+
item = Toolkit.newJMenuItem(Language.text("menu.debug.step"),
1388+
Language.text("menu.debug.step.keystroke"));
13881389
item.addActionListener(new ActionListener() {
13891390
public void actionPerformed(ActionEvent e) {
13901391
handleStep(0);
@@ -1393,7 +1394,8 @@ public void actionPerformed(ActionEvent e) {
13931394
debugMenu.add(item);
13941395
item.setEnabled(false);
13951396

1396-
item = Toolkit.newJMenuItemShift(Language.text("menu.debug.step_into"), KeyEvent.VK_J);
1397+
item = Toolkit.newJMenuItem(Language.text("menu.debug.step_into"),
1398+
Language.text("menu.debug.step_into.keystroke"));
13971399
item.addActionListener(new ActionListener() {
13981400
public void actionPerformed(ActionEvent e) {
13991401
handleStep(ActionEvent.SHIFT_MASK);
@@ -1402,7 +1404,8 @@ public void actionPerformed(ActionEvent e) {
14021404
debugMenu.add(item);
14031405
item.setEnabled(false);
14041406

1405-
item = Toolkit.newJMenuItemAlt(Language.text("menu.debug.step_out"), KeyEvent.VK_J);
1407+
item = Toolkit.newJMenuItem(Language.text("menu.debug.step_out"),
1408+
Language.text("menu.debug.step_out.keystroke"));
14061409
item.addActionListener(new ActionListener() {
14071410
public void actionPerformed(ActionEvent e) {
14081411
handleStep(ActionEvent.ALT_MASK);

todo.txt

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,44 @@ X text("test", 10, 10); is still slow with lots of fonts
1313
X https://bugs.openjdk.java.net/browse/JDK-8179209
1414
X added a note to the Known Issues section in the Changes wiki
1515
X update the about screen to 2019
16+
o report of a library or tool (probably includes 2.x? 1.x?) breaking things
17+
o NoSuchFieldError: useNativeSelect
18+
X https://github.com/processing/processing/issues/4821
19+
X closed, no response
20+
21+
22+
shortcuts
23+
X problems with non-US keyboards and some shortcuts
24+
X https://github.com/processing/processing/issues/2199
25+
_ Determine new keyboard shortcut for Step Out
26+
_ https://github.com/processing/processing/issues/3538
27+
28+
# Comment/Uncomment, Increase Indent, Decrease Indent
29+
menu.edit.comment_uncomment.keystroke = meta pressed SLASH
30+
menu.edit.increase_indent.keystroke = meta pressed CLOSE_BRACKET
31+
menu.edit.decrease_indent.keystroke = meta pressed OPEN_BRACKET
32+
# inside Editor.java
33+
34+
# Previous Tab, Next Tab (ignored on Linux, which is Page Up and Page Down)
35+
editor.header.previous_tab.keystroke = meta alt pressed LEFT
36+
editor.header.next_tab.keystroke = meta alt pressed RIGHT
37+
# inside EditorHeader.java
38+
39+
# Step, Step Into, and Step Out
40+
menu.debug.step.keystroke = meta pressed J
41+
menu.debug.step_into.keystroke = shift meta pressed J
42+
menu.debug.step_out.keystroke = meta alt pressed J
43+
# inside JavaEditor.java
44+
1645

1746
fixed earlier
1847
X Could not initialize class com.sun.jna.Native on startup (Windows)
1948
X https://github.com/processing/processing/issues/4929
2049
X closed earlier; fixed as best we could
2150
X sharing usage metrics about libraries
2251
X https://github.com/processing/processing/issues/4708
52+
X Determine shortcut for Export vs Use Selection for Find
53+
X https://github.com/processing/processing/issues/2985
2354

2455
contrib
2556
X Updated russian translation, now can choose russian in preferences
@@ -31,9 +62,9 @@ X https://github.com/processing/processing/issues/5246
3162
X https://github.com/processing/processing/pull/5654
3263
X console hiding button
3364
X https://github.com/processing/processing/pull/5115
34-
_ NullPointerException in Contribution Manager
35-
_ https://github.com/processing/processing/issues/5524
36-
_ https://github.com/processing/processing/pull/5742
65+
X NullPointerException in Contribution Manager when installing
66+
X https://github.com/processing/processing/issues/5524
67+
X https://github.com/processing/processing/pull/5742
3768

3869
jakub
3970
X Fix sketch exception getting hidden by warning
@@ -51,13 +82,14 @@ _ Find in Reference disabled for various keywords (draw, for, if, catch, while)
5182
_ https://github.com/processing/processing/issues/5562
5283
_ https://github.com/processing/processing/pull/5642
5384
_ discuss with Casey
54-
_ Welcome screen doesn't size properly for HiDPI screens
55-
_ https://github.com/processing/processing/issues/4896
5685

5786

58-
nasty ones
87+
88+
high-ish
5989
_ errors inside setup() aren't coming through at all?
6090
_ seen in Eclipse; have to turn on the debugger
91+
_ Welcome screen doesn't size properly for HiDPI screens
92+
_ https://github.com/processing/processing/issues/4896
6193

6294

6395
manager
@@ -100,16 +132,22 @@ _ clean Windows temp folders
100132
_ https://github.com/processing/processing/issues/1896
101133

102134

135+
modes
103136
_ sketch.properties not being written if initial mode is p5.js?
104137
_ when creating a sketch within non-Java mode, should write the settings file
105138
_ so that it re-loads in the proper environment
106139
_ remove sketch.properties when moving back to the default?
107140
_ or can we not do this, because it's used to set the 'next' mode
141+
_ allow modes to specify their own base file name
142+
_ need to move "is this a sketch?" handling into Mode
143+
_ fix extension check for other modes
144+
_ https://github.com/processing/processing/issues/3980
145+
108146

147+
sketch/launching
109148
_ what to double-click when opening p5 projects
110149
_ lack of a project file makes this a pain
111150
_ dropping a sketch folder onto the PDE should also be implemented
112-
113151
_ some type of sketch archive format for posting examples (.psk?)
114152
_ would be nice to open a sketch directly from a zip file
115153
_ https://github.com/processing/processing/issues/73
@@ -140,15 +178,6 @@ _ implement simple table for prefs?
140178
_ "error during export" message, but no error message contents come through
141179
_ e.g. https://github.com/processing/processing/issues/4792
142180

143-
_ report of a library or tool (probably includes 2.x? 1.x?) breaking things
144-
_ NoSuchFieldError: useNativeSelect
145-
_ https://github.com/processing/processing/issues/4821
146-
147-
_ allow modes to specify their own base file name
148-
_ need to move "is this a sketch?" handling into Mode
149-
_ fix extension check for other modes
150-
_ https://github.com/processing/processing/issues/3980
151-
152181
_ did we lose settings.path because it was too buggy?
153182
_ https://github.com/processing/processing/issues/3948
154183

@@ -200,19 +229,11 @@ _ https://github.com/processing/processing/issues/4353#issuecomment-237715947
200229
medium
201230
_ detect changes in case with libraries
202231
_ https://github.com/processing/processing/issues/4507
203-
_ make when opening new editor window, open on the same display as current
232+
_ when opening new editor window, open on the same display as current
204233
_ https://github.com/processing/processing/issues/4526
205234
_ Library path mismatch between processing-java and export
206235
_ https://github.com/processing/processing/issues/4493
207236

208-
shortcuts
209-
_ problems with non-US keyboards and some shortcuts
210-
_ https://github.com/processing/processing/issues/2199
211-
_ Determine shortcut for Export vs Use Selection for Find
212-
_ https://github.com/processing/processing/issues/2985
213-
_ Determine new keyboard shortcut for Step Out
214-
_ https://github.com/processing/processing/issues/3538
215-
216237

217238
needs more review
218239
_ createPreprocessor() added to JavaEditor, creating a mess

0 commit comments

Comments
 (0)