[josm-dev] MapMode - MouseWheelListener and KeyListener?
Paul Hartmann
phaaurlt at googlemail.com
Wed Sep 19 19:41:02 BST 2012
On 09/19/2012 03:55 PM, Russell Edwards wrote:
> Hello,
>
> Apologies for asking a beginner's question.
>
> I am writing a plugin which has its own MapMode. I need to catch mouse
> wheel and key press events. How can I do this?
>
> I have tried
>
> ... extends MapMode implements MouseWheelListener, KeyListener
>
> ... enterMode() {
> ...
> Main.map.mapView.addMouseWheelListener(this);
> Main.map.mapView.addKeyListener(this);
> ...
> }
>
> but the listeners never seem to get called. Moreover the map still zooms
> in and out when the wheel is moved.
>
> Thanks in advance for your help and patience,
I put your code in SelectAction and MouseWheelListener worked directly.
Not sure if you can easily suppress zoom, though. What is your mapmode
about?
Other plugins have a similar similar setup, e.g. alignways has a mapmode
with MouseListener. In order to catch keystrokes, you should try
AWTEventListener.
Paul
-------------- next part --------------
A non-text attachment was scrubbed...
Name: listeners.diff
Type: text/x-patch
Size: 2137 bytes
Desc: not available
URL: <http://lists.openstreetmap.org/pipermail/josm-dev/attachments/20120919/53647092/attachment.bin>
More information about the josm-dev
mailing list