RE: [OpenMap Users] Implementing a Layer that Hijacks Mouse Clicks

From: Renton Ian <ian.renton_at_uk.atlas-elektronik.com>
Date: Fri, 18 May 2012 09:04:51 +0100

Don,

Thanks for your reply.

I'm trying to implement a layer that sits on the top of the layer stack and displays various information, but that the user can also click on elements of, e.g. "click here to expand this section" or "click here to hide" buttons.

I am drawing these elements using OMGraphic types, and extending OMGraphicHandlerLayer, but I want the layer to handle mouse clicks on the elements in special ways rather than the standard OMGraphic-editing way.

So for example, if I were to draw a button as an OMRect, when the user clicks on it, I don't want them to select the OMRect - I want the layer to notice that it's been clicked on, and fire off some handling method.

Ideally I would also like clicks that are *not* on an element in my layer to fall through, but as my layer can be switched on and off that isn't a great concern.

It dawns on me that it might be a better idea to do something with the OverlayMapPanel rather than implementing this as a proper layer, would you agree? In the mean time I will look at InteractionLayer and see if I understand more after reading the comments there.

Thanks,

Ian

-- 
Ian Renton
UX / Software Engineer
ATLAS ELEKTRONIK UK
Atlas House, Dorset Green Tech. Park, DT2 8ZB, U.K.
Tel: +44 (0) 1305 212341
-----Original Message-----
From: Don Dietrick [mailto:dfdietrick_at_gmail.com] 
Sent: 17 May 2012 22:39
To: Renton Ian
Cc: openmap-users_at_bbn.com
Subject: Re: [OpenMap Users] Implementing a Layer that Hijacks Mouse Clicks
Hi Ian,
There's a better way to do what you want to do, but I'm not sure what you want to do.  Do you want to do anything in particular with the mouse events, or how to interact with OMGraphics on your layer?  You get a lot of help doing this if your overlay layer extends OMGraphicHandlerLayer.  If you are extending OMGraphicHandlerLayer and want events to fall through to other layers, set the consumeEvents flag to false on your layer.
If you want to interact with the OMGraphics on your layer, I suggest taking a look at the code for the com.bbn.openmap.layer.learn.InteractionLayer.  There are comments in the code explaining all the different aspects of receiving and managing MouseEvents with the current MapMouseModes.
If you want to do something else, or have question about that layer or your layer, let me know.  If you have more specifics that'll help, too.
Cheers,
Don
On Thu, May 17, 2012 at 5:29 AM, Renton Ian <ian.renton_at_uk.atlas-elektronik.com> wrote:
> Hi,
>
> I am attempting to create an OpenMap layer that handles mouse events internally.
>
> OpenMap's Layer.addMouseListener() method prevents me from attaching my own mouse listener as it rejects any listener that isn't part of javax.swing.  The Javadoc helpfully points out that this is to stop classes stealing the mouse events and thus not letting them fall through to the map.
>
> However, that's exactly what I want to do.  My "overlay"-type layer gets switched on and off, but when it's on, it sits on top and steals mouse clicks to handle them itself rather than passing them through to the layers below.
>
> Can I only do this by overriding OpenMap's Layer class to remove the check, or is there a better way to do what I'm trying to do?
>
> Thanks,
>
> Ian
>
> --
> Ian Renton
> UX / Software Engineer
> ATLAS ELEKTRONIK UK
> Atlas House, Dorset Green Tech. Park, DT2 8ZB, U.K.
> Tel: +44 (0) 1305 212341
> The information contained within this e-mail and any files attached to this e-mail are private and in addition may include commercially sensitive information. The contents of this e-mail are for the intended recipient only and therefore if you wish to disclose the information contained within this e-mail or attached files, please contact the sender prior to any such disclosure.
>
> If you are not the intended recipient, any disclosure, copying or distribution is prohibited. Please also contact the sender and inform them of the error and delete the e-mail, including any attached files from your system.
>
> Atlas Elektronik UK Limited Registered Office Meadows Road, Queensway 
> Meadows, Newport, South Wales NP19 4SS, UK.  Company No. 05582639
>
> --
> [To unsubscribe to this list send an email to "majdart_at_bbn.com"
> with the following text in the BODY of the message "unsubscribe 
> openmap-users"]
The information contained within this e-mail and any files attached to this e-mail are private and in addition may include commercially sensitive information. The contents of this e-mail are for the intended recipient only and therefore if you wish to disclose the information contained within this e-mail or attached files, please contact the sender prior to any such disclosure.
If you are not the intended recipient, any disclosure, copying or distribution is prohibited. Please also contact the sender and inform them of the error and delete the e-mail, including any attached files from your system. 
Atlas Elektronik UK Limited Registered Office Meadows Road, Queensway Meadows, Newport, South Wales NP19 4SS, UK.  Company No. 05582639
--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Fri May 18 2012 - 04:06:04 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:10 EDT