Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSOC2020: Ctrl-shift-U does not work work when editor is focused #9895 #9948

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions app/src/processing/app/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -670,7 +673,15 @@ private void buildSketchMenu(JMenu sketchMenu) {
item.addActionListener(event -> handleExport(false));
sketchMenu.add(item);

item = newJMenuItemShift(tr("Upload Using Programmer"), 'U');
// 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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have helpers to recognize operating systems, it's better to use them.
THis could become

if (OSUtils.isWindows()) {
  item = newJMenuItemShift(tr("Upload Using Programmer"), 'U');
} else {
  item = newJMenuItemAlt(tr("Upload Using Programmer"), 'U');
}

Copy link
Author

@yzykov yzykov Mar 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I did not know that.
I will commit the change with Arduino Helpers.

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');
}
item.addActionListener(event -> handleExport(true));
sketchMenu.add(item);

Expand Down Expand Up @@ -1350,7 +1361,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;
}

Expand Down