Skip to content

Commit 3d5151f

Browse files
Matthijs Kooijmanlmihalkovic
Matthijs Kooijman
authored andcommitted
Move ctrl-tab and ctrl-shift-tab handling into EditorHeader
Previously, EditorListener handled these keys, by registering a handler in the text area. This meant that they would only work while the text area was focused. By registering the keys as WHEN_IN_FOCUSED_WINDOW bindings, they can always be handled, and EditorHeader seems like a more appropriate place. Note that this does not currently work (so this commit breaks these keys), since these keys are also handled in a few different places as well, preventing these newly added keybindings to take effect. This will be fixed in the next commit. One additional change is that previously, these keybindings did not work when the text area was readonly. This was probably a remnant from when EditorListener took care of a lot of other editing keybindings, but this does not make much sense anymore now. Finally, with the old bindings, ctrl-shift-tab did not (seem to) work. What happened is that the binding for ctrl-tab did not check the shift state, so both bindings would fire on ctrl-shift-tab, switching forward and back again, making it seem the keys did not work. The Swing keybinding mechanism that is now used for these bindings checks the complete keystroke, including all modifier keys, so this problem is fixed by this change. References arduino#195
1 parent 1a8ae26 commit 3d5151f

File tree

2 files changed

+4
-25
lines changed

2 files changed

+4
-25
lines changed

app/src/processing/app/EditorHeader.java

+4
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ public class Actions {
110110
Keys.bind(EditorHeader.this, newTab);
111111
Keys.bind(EditorHeader.this, prevTab);
112112
Keys.bind(EditorHeader.this, nextTab);
113+
114+
// Add alternative keybindings to switch tabs
115+
Keys.bind(EditorHeader.this, prevTab, Keys.ctrlShift(KeyEvent.VK_TAB));
116+
Keys.bind(EditorHeader.this, nextTab, Keys.ctrl(KeyEvent.VK_TAB));
113117
}
114118
}
115119
public Actions actions = new Actions();

app/src/processing/app/EditorListener.java

-25
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,6 @@ public void keyTyped(KeyEvent event) {
3434

3535
@Override
3636
public void keyPressed(KeyEvent event) {
37-
38-
SketchTextArea textarea = editor.getTextArea();
39-
40-
if (!textarea.isEditable()) return;
41-
42-
Sketch sketch = editor.getSketch();
43-
44-
int code = event.getKeyCode();
45-
46-
// Navigation..
47-
if ((event.getModifiers() & CTRL) == CTRL && code == KeyEvent.VK_TAB) {
48-
sketch.handleNextCode();
49-
}
50-
51-
// Navigation..
52-
// FIXME: not working on LINUX !!!
53-
if ((event.getModifiers() & CTRL_SHIFT) == CTRL_SHIFT && code == KeyEvent.VK_TAB) {
54-
sketch.handlePrevCode();
55-
}
56-
57-
// if (event.isAltDown() && code == KeyEvent.VK_T) {
58-
// int line = textarea.getCaretLineNumber();
59-
// textarea.setActiveLineRange(line, line + 3);
60-
// }
61-
6237
}
6338

6439
@Override

0 commit comments

Comments
 (0)