Skip to content

Commit 8008163

Browse files
committed
GSOC2020: Ctrl-shift-U does not work work when editor is focused arduino#9895
1 parent a1e43ce commit 8008163

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

app/src/processing/app/Editor.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ public boolean test(SketchController controller) {
169169
/** Command-Option on Mac OS X, Ctrl-Alt on Windows and Linux */
170170
static final int SHORTCUT_ALT_KEY_MASK = ActionEvent.ALT_MASK |
171171
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
172+
/** Command-Option on Mac OS X, Ctrl-Shift on Windows and Linux */
173+
static final int SHORTCUT_SHIFT_KEY_MASK = ActionEvent.SHIFT_MASK |
174+
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
172175

173176
/**
174177
* true if this file has not yet been given a name by the user
@@ -670,7 +673,15 @@ private void buildSketchMenu(JMenu sketchMenu) {
670673
item.addActionListener(event -> handleExport(false));
671674
sketchMenu.add(item);
672675

673-
item = newJMenuItemShift(tr("Upload Using Programmer"), 'U');
676+
// Since CTRL+SHIFT+U is not working on iBus keyboard input method
677+
// Lets redirect the shorcut for Linux to CTRL+ALT+U
678+
// Leaving the preexisting behaviour for Windows & Mac OS
679+
String OS = System.getProperty("os.name").toLowerCase();
680+
if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0){
681+
item = newJMenuItemAlt(tr("Upload Using Programmer"), 'U');
682+
} else {
683+
item = newJMenuItemShift(tr("Upload Using Programmer"), 'U');
684+
}
674685
item.addActionListener(event -> handleExport(true));
675686
sketchMenu.add(item);
676687

@@ -1350,7 +1361,7 @@ static public JMenuItem newJMenuItem(String title, int what) {
13501361
// Control + Shift + K seems to not be working on linux (Xubuntu 17.04, 2017-08-19)
13511362
static public JMenuItem newJMenuItemShift(String title, int what) {
13521363
JMenuItem menuItem = new JMenuItem(title);
1353-
menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_KEY_MASK | ActionEvent.SHIFT_MASK));
1364+
menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_SHIFT_KEY_MASK));
13541365
return menuItem;
13551366
}
13561367

0 commit comments

Comments
 (0)