Skip to content

Commit aad493e

Browse files
committed
Merge pull request processing#4457 from JakubValtar/comment-key-fix
Make Comment/Uncomment trigger on numpad slash
2 parents 34c5a63 + eccbd35 commit aad493e

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

app/src/processing/app/ui/Editor.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,19 @@ public void paintComponent(Graphics g) {
260260
textarea.setRightClickPopup(new TextAreaPopup());
261261
textarea.setHorizontalOffset(JEditTextArea.leftHandGutter);
262262

263+
{ // Hack: add Numpad Slash as an alternative shortcut for Comment/Uncomment
264+
int modifiers = Toolkit.awtToolkit.getMenuShortcutKeyMask();
265+
KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_DIVIDE, modifiers);
266+
final String ACTION_KEY = "COMMENT_UNCOMMENT_ALT";
267+
textarea.getInputMap().put(keyStroke, ACTION_KEY);
268+
textarea.getActionMap().put(ACTION_KEY, new AbstractAction() {
269+
@Override
270+
public void actionPerformed(ActionEvent e) {
271+
handleCommentUncomment();
272+
}
273+
});
274+
}
275+
263276
footer = createFooter();
264277

265278
upper.add(textarea);

0 commit comments

Comments
 (0)