[josm-dev] MapMode - MouseWheelListener and KeyListener?

Paul Hartmann phaaurlt at googlemail.com
Thu Sep 20 19:55:51 BST 2012


On 09/20/2012 08:25 AM, Russell Edwards wrote:
> On 20/09/12 04:41, Paul Hartmann wrote:
>>
>> 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.
>
> Thanks very much -- all working now.
>
> I have also successfully temporarily disabled map zooming  using
> Main.map.mapView.getMouseWheelListeners() and looping
> Main.map.mapView.removeMouseWheelListener(). I do this when my mode gets
> a mousePressed, and then reinstate them all with
> Main.map.mapView.addMouseWheelListener() when I get mouseReleased.
>
> Is this allowed? It's a bit sneaky as the listeners are added by
> mapView's private member MapMover. Maybe mapView should have public
> lockMap() and unlockMap() methods?

Take care that the listeners are added back, when the user switches to a 
default mapmode, otherwise do what you like, it's your project! ;)
You are welcome to send core patches if needed for a plugin.

Paul




More information about the josm-dev mailing list