Re: Antwort: Intercepting keystrokes in plugin
Posted by
Nico Stuurman-4 on
Jul 22, 2009; 3:58pm
URL: http://imagej.273.s1.nabble.com/Intercepting-keystrokes-in-plugin-tp3691678p3691683.html
Hi Joachim and Johannes,
>> you mean, your plugin kets the keys as it should be, but it will
>> ALSO be
>> handled by ImageJ?
>> KeyEvent.consume
>>
>> methods, which marks an event as already fully handled, you might
>> give
>> it a try!?
>
> That relies on your KeyListener being called first, which is not good.
Apparently, Listeners are called in reverse order of addition, which
in this case should guarantee that the plugin's listener is called
first. However, propagation of the InputEvent is not stopped when the
consume function is called, rather, a Listener should check the
isConsumed() flag on the inputEvent and take action accordingly. I
had a quick look at the ImageJ code to handle KeyPresses and do not
see the isConsumed() check there. It seems useful to add so that
plugin writers can use the "consume" method to signal ImageJ that they
have handled an event.
I found the following link helpful:
http://elliotth.blogspot.com/2004/08/implementing-java-listeners.htmlBest,
Nico