Customizable Shortcuts

Post a reply

:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Topic review

Expand view Topic review: Customizable Shortcuts

Re: Customizable Shortcuts

Post by robert » Wed Jan 02, 2013 6:12 pm

As a compromise, I could check the input method locale (there's some way to check that, can't remember it offhand, and it might be more inline with what we want as opposed to Locale.getDefault()), and if it's for a language that typically uses QWERTZ keyboards, I could add an additional key binding for ToggleLineCommentAction, mapping from Ctrl+Shift+7. That should appease my "safety" worries, and make things work as expected for you out of the box.

Sound good? Of course, if there were other standard actions that don't work in RSTA, I'd need to know about them as well, otherwise they'd stay broken.

Re: Customizable Shortcuts

Post by Guest » Wed Jan 02, 2013 3:01 pm

Thanks for the quick reply. I just found out that my IDE (IntelliJ) has the same problems when it comes to shortcuts, as commenting out a line is also CTRL-/ and not working :(
So as this seems to be a general issue, my initial idea was to make the shortcut configurable.
With the help of your code I was able to map the ToggleCommentAction to an additional keystroke that works on a QWERTZ layout.

I think i will make the layout/shortcuts chooseable within my application then.

best regards

Re: Customizable Shortcuts

Post by robert » Wed Jan 02, 2013 2:00 pm "fixed" the problem in 2.0.5 by simply reverting the relevant code to the way it was pre-2.0.5. So it sounds like everything is working as expected.

The issue is that, from Java, it is difficult, and likely error prone, to detect the user's keyboard layout and adjust the default keyboard shortcuts appropriately. I don't believe it's as simple as using the default Locale (although that may be sufficient in many cases), as an application's locale can be toggled separately from the system locale and keyboard layout. I could be wrong of course, and I'm open to ideas. But I'll only implement something if it's foolproof.

FWIW, you can install this shortcut for your QWERTZ users if you want as follows (untested):

java code:

InputMap im = textArea.getInputMap();
// Old shortcut doesn't hurt, but might as well remove it.
im.remove(KeyStroke.getKeyStroke(KeyEvent.VK_SLASH, textArea.getToolkit().getMenuShortcutKeyMask());
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_SLASH, InputEvent.SHIFT_MASK|InputEvent.CTRL_MASK), RSyntaxTextAreaEditorKit.rstaToggleCommentAction);

Re: Customizable Shortcuts

Post by InV » Wed Jan 02, 2013 12:20 pm

I was using 2.0.2 and the behavior was, that with a QWERTZ-layout one is not able to use the comment toggle - nothing happens.
The problem is that with this layout one has to press SHIFT-7 to get a slash character, so to get STRG-/ one would have to press STRG-SHIFT-7 but that does not do anything.
If I change to QWERTY-layout everything works as expected.
Just installed but that does not change this behavior.

Maybe you could install the QWERTZ (german) layout in windows, as i did with the QWERTY to experience the problem.

Re: Customizable Shortcuts

Post by robert » Wed Dec 12, 2012 4:45 am

This is a bug introduced in the 2.0.5 release; see this thread for a discussion. I hope to make a minor update release very soon that fixes just this issue, but first I have to determine a fix that works on Windows, Linux, and OS X across the different keyboard layouts (qwerty, azerty, I believe you're using qwertz?).

Actually, are you using 2.0.5 or 2.0.4? What incorrect/unexpected behavior does each release give you? You might be a good data point for testing a fix :) (I currently have QWERTY and Swedish keyboard layout). Suggestions to fix it are of course welcome.

Customizable Shortcuts

Post by InV » Tue Dec 11, 2012 1:07 pm


I am using RSyntaxTextArea with a german keyboard layout. It seems some of the shortcuts are not working (e.g. toggle comments CTRL-/) as in the german layout some of the keys are special keys that are activated using SHIFT.
Is there a workaround for this problem or any chance this gets fixed/customizable in a future version?

best regards