From 15fc84e0216ffabeb75b58e735dd15a984b418b7 Mon Sep 17 00:00:00 2001 From: yzykov Date: Fri, 27 Mar 2020 14:56:10 -0700 Subject: [PATCH 1/3] Ctrl-shift-U does not work work when editor is focused #9895 --- app/src/processing/app/Editor.java | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 2ec29c498cb..469f4dd2e6d 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -169,6 +169,9 @@ public boolean test(SketchController controller) { /** Command-Option on Mac OS X, Ctrl-Alt on Windows and Linux */ static final int SHORTCUT_ALT_KEY_MASK = ActionEvent.ALT_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); + /** Command-Option on Mac OS X, Ctrl-Shift on Windows and Linux */ + static final int SHORTCUT_SHIFT_KEY_MASK = ActionEvent.SHIFT_MASK | + Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); /** * true if this file has not yet been given a name by the user @@ -670,9 +673,22 @@ private void buildSketchMenu(JMenu sketchMenu) { item.addActionListener(event -> handleExport(false)); sketchMenu.add(item); - item = newJMenuItemShift(tr("Upload Using Programmer"), 'U'); - item.addActionListener(event -> handleExport(true)); - sketchMenu.add(item); + // Since CTRL+SHIFT+U is not working on iBus keyboard input method + // Lets redirect the shorcut for Linux to CTRL+ALT+U + // Leaving the preexisting behaviour for Windows & Mac OS + String OS = System.getProperty("os.name").toLowerCase(); + if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0) + { + item = newJMenuItemAlt(tr("Upload Using Programmer"), 'U'); + item.addActionListener(event -> handleExport(true)); + sketchMenu.add(item); + } + else + { + item = newJMenuItemShift(tr("Upload Using Programmer"), 'U'); + item.addActionListener(event -> handleExport(true)); + sketchMenu.add(item); + } item = newJMenuItemAlt(tr("Export compiled Binary"), 'S'); item.addActionListener(event -> { @@ -1350,7 +1366,7 @@ static public JMenuItem newJMenuItem(String title, int what) { // Control + Shift + K seems to not be working on linux (Xubuntu 17.04, 2017-08-19) static public JMenuItem newJMenuItemShift(String title, int what) { JMenuItem menuItem = new JMenuItem(title); - menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_KEY_MASK | ActionEvent.SHIFT_MASK)); + menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_SHIFT_KEY_MASK)); return menuItem; } From 4197ce9eeada61ce751e56a862eb55317c4a7424 Mon Sep 17 00:00:00 2001 From: yzykov Date: Fri, 27 Mar 2020 17:24:55 -0700 Subject: [PATCH 2/3] Modifying the logic --- app/src/processing/app/Editor.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 469f4dd2e6d..45ab53ae725 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -677,18 +677,14 @@ private void buildSketchMenu(JMenu sketchMenu) { // Lets redirect the shorcut for Linux to CTRL+ALT+U // Leaving the preexisting behaviour for Windows & Mac OS String OS = System.getProperty("os.name").toLowerCase(); - if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0) + if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0) { item = newJMenuItemAlt(tr("Upload Using Programmer"), 'U'); - item.addActionListener(event -> handleExport(true)); - sketchMenu.add(item); - } - else - { + } else { item = newJMenuItemShift(tr("Upload Using Programmer"), 'U'); - item.addActionListener(event -> handleExport(true)); - sketchMenu.add(item); } + item.addActionListener(event -> handleExport(true)); + sketchMenu.add(item); item = newJMenuItemAlt(tr("Export compiled Binary"), 'S'); item.addActionListener(event -> { From 1a11fe980dae251edecef9e1ea0c2edfd62d0c51 Mon Sep 17 00:00:00 2001 From: yzykov Date: Fri, 27 Mar 2020 20:56:09 -0700 Subject: [PATCH 3/3] Java CI failed Retrigger --- app/src/processing/app/Editor.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 45ab53ae725..3b9eb3a162b 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -169,9 +169,6 @@ public boolean test(SketchController controller) { /** Command-Option on Mac OS X, Ctrl-Alt on Windows and Linux */ static final int SHORTCUT_ALT_KEY_MASK = ActionEvent.ALT_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); - /** Command-Option on Mac OS X, Ctrl-Shift on Windows and Linux */ - static final int SHORTCUT_SHIFT_KEY_MASK = ActionEvent.SHIFT_MASK | - Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); /** * true if this file has not yet been given a name by the user @@ -677,8 +674,7 @@ private void buildSketchMenu(JMenu sketchMenu) { // Lets redirect the shorcut for Linux to CTRL+ALT+U // Leaving the preexisting behaviour for Windows & Mac OS String OS = System.getProperty("os.name").toLowerCase(); - if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0) - { + if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0) { item = newJMenuItemAlt(tr("Upload Using Programmer"), 'U'); } else { item = newJMenuItemShift(tr("Upload Using Programmer"), 'U'); @@ -1362,7 +1358,7 @@ static public JMenuItem newJMenuItem(String title, int what) { // Control + Shift + K seems to not be working on linux (Xubuntu 17.04, 2017-08-19) static public JMenuItem newJMenuItemShift(String title, int what) { JMenuItem menuItem = new JMenuItem(title); - menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_SHIFT_KEY_MASK)); + menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_KEY_MASK | ActionEvent.SHIFT_MASK)); return menuItem; }