Login  Register

Re: Using keyboard with plugin

Posted by Wayne Rasband on Jan 12, 2007; 9:04pm
URL: http://imagej.273.s1.nabble.com/Using-keyboard-with-plugin-tp3700619p3700620.html

Check "Require Command Key for Shortcuts" in Edit>Options>Misc and the
user will have to hold down the control key (command key on the Mac) to
use the built in shortcuts. A plugin can enable/disable this option by
assigning true or false to the public Prefs.requireControlKey variable.

-wayne


On Jan 12, 2007, at 11:30 AM, Richard Ansorge wrote:

> 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.
>