You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Joel Biddier <jb...@gmail.com> on 2010/08/16 05:54:00 UTC
Cannot stop default arrow key actions - Solution?
I seem to have "fixed" the problem. But I an not sure it is the best way to
do it...
I extended the JSVGCanvas and orverrided the installKeyboardActions()
method. In the installKeyboardActions() I commented out the key maps I did
not what.
Not sure if this is a good way to do this? I does work. Any suggestions of a
better way, please tell me.
Thanks.
Below is my code:
public class MyCanvas extends JSVGCanvas {
public MyCanvas() {
super();
}
public MyCanvas(SVGUserAgent ua, boolean eventsEnabled, boolean
selectableText) {
super();
}
// Override the installKeyboardActions() Method in the implementation.
@Override
protected void installKeyboardActions() {
InputMap inputMap = getInputMap(JComponent.WHEN_FOCUSED);
KeyStroke key;
// I comment out the four key Actions I don't want. (So I my
Interactor can use them exclusively.)
/*
key = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0);
inputMap.put(key, SCROLL_RIGHT_ACTION);
key = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0);
inputMap.put(key, SCROLL_LEFT_ACTION);
key = KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0);
inputMap.put(key, SCROLL_UP_ACTION);
key = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0);
inputMap.put(key, SCROLL_DOWN_ACTION);
*/
key = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,
KeyEvent.SHIFT_MASK);
inputMap.put(key, FAST_SCROLL_RIGHT_ACTION);
key = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.SHIFT_MASK);
inputMap.put(key, FAST_SCROLL_LEFT_ACTION);
key = KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.SHIFT_MASK);
inputMap.put(key, FAST_SCROLL_UP_ACTION);
key = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.SHIFT_MASK);
inputMap.put(key, FAST_SCROLL_DOWN_ACTION);
key = KeyStroke.getKeyStroke(KeyEvent.VK_I, KeyEvent.CTRL_MASK);
inputMap.put(key, ZOOM_IN_ACTION);
key = KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK);
inputMap.put(key, ZOOM_OUT_ACTION);
key = KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_MASK);
inputMap.put(key, RESET_TRANSFORM_ACTION);
}
}
Re: Cannot stop default arrow key actions - Solution?
Posted by Helder Magalhães <he...@gmail.com>.
Hi Joel,
Please reply to previous thread messages (in this case, [1]) in order
to avoid creating multiple thread about the same subject: it eases a
bit searching and browsing through the mailing list, etc.. ;-)
> I seem to have "fixed" the problem. But I an not sure it is the best way to
> do it...
>
> I extended the JSVGCanvas and orverrided the installKeyboardActions()
> method. In the installKeyboardActions() I commented out the key maps I did
> not what.
>
> Not sure if this is a good way to do this? I does work. Any suggestions of a
> better way, please tell me.
I believe there's currently no way of doing it differently. I've
reported bug 49762 [2] so that it doesn't get lost. Please comment
and/or add yourself to the CC list if you want to get notified of
changes. As always, patches are welcome so consider contributing one!
;-)
> Below is my code:
[...]
> // I comment out the four key Actions I don't want. (So I my
> Interactor can use them exclusively.)
> /*
> key = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0);
> inputMap.put(key, SCROLL_RIGHT_ACTION);
>
> key = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0);
> inputMap.put(key, SCROLL_LEFT_ACTION);
>
> key = KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0);
> inputMap.put(key, SCROLL_UP_ACTION);
>
> key = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0);
> inputMap.put(key, SCROLL_DOWN_ACTION);
> */
>
> key = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,
> KeyEvent.SHIFT_MASK);
> inputMap.put(key, FAST_SCROLL_RIGHT_ACTION);
>
> key = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.SHIFT_MASK);
> inputMap.put(key, FAST_SCROLL_LEFT_ACTION);
>
> key = KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.SHIFT_MASK);
> inputMap.put(key, FAST_SCROLL_UP_ACTION);
>
> key = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.SHIFT_MASK);
> inputMap.put(key, FAST_SCROLL_DOWN_ACTION);
Maybe you want to disable these as well? (Shift+cursor keys.) ;-)
Cheers,
Helder
[1] http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik-users/201008.mbox/%3CAANLkTi=p=KDCL3VR1SEXhrJDxw+aHM4gu1AeBamtd7dy@mail.gmail.com%3E
[2] https://issues.apache.org/bugzilla/show_bug.cgi?id=49762
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org