Login  Register

Using keyboard with plugin

Posted by Richard Ansorge on Jan 12, 2007; 4:30pm
URL: http://imagej.273.s1.nabble.com/Using-keyboard-with-plugin-tp3700619.html

Hi,

I am trying to develop a PluginFilter for simple Image Editor which uses
keyboard commands. I am reading the keyboard using the keyListener.java
example.

Everything works, EXCEPT most keystrokes are also captured as hotkeys by
other parts of ImageJ; e.g. "1" by the gel package. Is there any way of
preventing this?  

I have tried adding a "consume" to the keyPressed function but that does not
work:

        public void keyPressed(KeyEvent e) {
                int keyCode = e.getKeyCode();
                char keyChar = e.getKeyChar();
                int flags = e.getModifiers();
                IJ.write("keyCode=" + keyCode + " (" +
KeyEvent.getKeyText(keyCode)
                        + ") keyChar=\"" + keyChar + "\" (" + (int)keyChar +
") "
                        + KeyEvent.getKeyModifiersText(flags));

                e.consume(); //ADDED to original - does not work
        }

I am aware that the keypad is free to use but I am left handed and therefore
not keen on this..

Thanks for any help!

Richard Ansorge.