Use ctrl-pageup/down on Linux for prev/next tab (fixes #3416)

This commit is contained in:
Ben Fry
2015-08-09 23:04:18 -04:00
parent 953ac446cc
commit 1271583619
3 changed files with 30 additions and 48 deletions
-1
View File
@@ -38,7 +38,6 @@ import javax.swing.event.TreeExpansionEvent;
import javax.swing.event.TreeExpansionListener;
import javax.swing.tree.*;
import processing.app.contrib.Contribution;
import processing.app.contrib.ContributionType;
import processing.app.contrib.ExamplesContribution;
import processing.app.syntax.*;
+28 -47
View File
@@ -435,43 +435,15 @@ public class EditorHeader extends JComponent {
*/
}
JMenuItem item;
InputMap inputMap = editor.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
ActionMap actionMap = editor.getRootPane().getActionMap();
final JRootPane rootPane = editor.getRootPane();
InputMap inputMap =
rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
ActionMap actionMap = rootPane.getActionMap();
Action action;
String mapKey;
KeyStroke keyStroke;
// maybe this shouldn't have a command key anyways..
// since we're not trying to make this a full ide..
//item = Editor.newJMenuItem("New", 'T');
/*
item = Editor.newJMenuItem("Previous", KeyEvent.VK_PAGE_UP);
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("prev");
}
});
if (editor.sketch != null) {
item.setEnabled(editor.sketch.codeCount > 1);
}
menu.add(item);
item = Editor.newJMenuItem("Next", KeyEvent.VK_PAGE_DOWN);
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("ext");
}
});
if (editor.sketch != null) {
item.setEnabled(editor.sketch.codeCount > 1);
}
menu.add(item);
menu.addSeparator();
*/
//item = new JMenuItem("New Tab");
item = Toolkit.newJMenuItemShift(Language.text("editor.header.new_tab"), KeyEvent.VK_N);
action = new AbstractAction() {
@Override
@@ -491,12 +463,6 @@ public class EditorHeader extends JComponent {
@Override
public void actionPerformed(ActionEvent e) {
editor.getSketch().handleRenameCode();
/*
// this is already being called by nameCode(), the second stage of rename
if (editor.sketch.current == editor.sketch.code[0]) {
editor.sketchbook.rebuildMenus();
}
*/
}
};
item.addActionListener(action);
@@ -527,33 +493,48 @@ public class EditorHeader extends JComponent {
menu.addSeparator();
// KeyEvent.VK_LEFT and VK_RIGHT will make Windows beep
item = Toolkit.newJMenuItemAlt(Language.text("editor.header.previous_tab"), KeyEvent.VK_LEFT);
final String prevTab = Language.text("editor.header.previous_tab");
if (Base.isLinux()) {
item = Toolkit.newJMenuItem(prevTab, KeyEvent.VK_PAGE_UP);
} else {
item = Toolkit.newJMenuItemAlt(prevTab, KeyEvent.VK_LEFT);
}
action = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
// Sketch sketch = editor.getSketch();
// sketch.setCurrentCode(sketch.getCurrentCodeIndex() - 1);
editor.getSketch().handlePrevCode();
}
};
mapKey = "editor.header.previous_tab";
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Toolkit.SHORTCUT_ALT_KEY_MASK);
if (Base.isLinux()) {
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, Toolkit.SHORTCUT_KEY_MASK);
} else {
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Toolkit.SHORTCUT_ALT_KEY_MASK);
}
inputMap.put(keyStroke, mapKey);
actionMap.put(mapKey, action);
item.addActionListener(action);
menu.add(item);
item = Toolkit.newJMenuItemAlt(Language.text("editor.header.next_tab"), KeyEvent.VK_RIGHT);
final String nextTab = Language.text("editor.header.next_tab");
if (Base.isLinux()) {
item = Toolkit.newJMenuItem(nextTab, KeyEvent.VK_PAGE_DOWN);
} else {
item = Toolkit.newJMenuItemAlt(nextTab, KeyEvent.VK_RIGHT);
}
action = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
// Sketch sketch = editor.getSketch();
// sketch.setCurrentCode(sketch.getCurrentCodeIndex() + 1);
editor.getSketch().handleNextCode();
}
};
mapKey = "editor.header.next_tab";
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Toolkit.SHORTCUT_ALT_KEY_MASK);
if (Base.isLinux()) {
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, Toolkit.SHORTCUT_KEY_MASK);
} else {
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Toolkit.SHORTCUT_ALT_KEY_MASK);
}
inputMap.put(keyStroke, mapKey);
actionMap.put(mapKey, action);
item.addActionListener(action);
+2
View File
@@ -6,6 +6,8 @@ X https://github.com/processing/processing/issues/3306
X 'examples' shows as a folder in the sketchbook window
X Foundation library examples should appear under "Core" or "Foundation"
X https://github.com/processing/processing/issues/3524
X Use ctrl-pageup/down on Linux for prev/next tab
X https://github.com/processing/processing/issues/3416
cleaning/earlier
X move to launch4j 3.7 http://launch4j.sourceforge.net/