Possible to make a layer completely ignore the mouse, i.e. passthru?

1634
6
02-11-2013 12:18 PM
RexBradford
New Contributor II
I have a GraphicsLayer which is used to display a graphic pointer overlay, and I would like it to be completely invisible to the mouse.

layer.disableMouseEvents() almost owrks - mouse clicks pass through to underlying layers.

But the underlying layers do not get onMouseOver() events, which is what I use to set the cursor, display tooltips, etc.

Is there a way to make the Graphics layer completely transparent to mouse movement as well as clicks?  Or should it do that already and I am missing something or have a bug?

Thank you,

Rex Bradford
Direct Relief International
0 Kudos
6 Replies
DianaBenedict
Occasional Contributor III
Have you looked at this Thread.  There is a link to a web site.  Looks like he had to load the graphics as transparent features so he can control the mouseover event.  Maybe this can help:
http://forums.arcgis.com/threads/77010-Cursor-Hover-Style-Over-DynamicMapService
0 Kudos
RexBradford
New Contributor II
Have you looked at this Thread.  There is a link to a web site.  Looks like he had to load the graphics as transparent features so he can control the mouseover event.  Maybe this can help:
http://forums.arcgis.com/threads/77010-Cursor-Hover-Style-Over-DynamicMapService


I think my problem is a little different.  Rather than trying to use a transparent layer to catch mouse events, I want to do the opposite.  I want a visible layer which completely ignores the mouse, including hover as well as click.

I tried using disableMouseEvents(), but that has two problems:

1. If I click on the layer, the underlying map gets the event with evt.graphic set to undefined, EVEN IF underneath my trying-to-be-invisible-to-the-mouse graphic there is another layer that really should have gotten the event.  It seems that disableMouseEvents() throws up its hands and passes off to map, instead of looking at what is under the mouse at that spot.

2. The trying-to-be-invisible-to-the-mouse graphic interferes with mouseover and mouseout events.  I have an underlying layer (filled in countries) which changes the cursor when the mouse is inside it, but that layer gets a mouseout when I enter the trying-to-be-invisible-to-mouse-events overlay.

An alternative, though unattractive, would be to somehow traverse the layers to see which one really is under the mouse, in effect doing the esri toolkit's job for it.  Is this possible even if undesirable?

Rex Bradford
Direct Relief International
0 Kudos
DianaBenedict
Occasional Contributor III
Again not sure if this will help but according to ESRI documentation, "The default behavior of a graphic object when it is clicked is to display the infoWindow, provided that an InfoTemplate object has been defined"

To test this, you can make sure that you do not define an InfoTemplate and/or an InfoWindow for the map and see if this "turns off" the onClick event that is automatically added with a Graphic layer when an InfoTemplate has been set. 

Essentially (in theory) you need to disconnect the mouse events that can be set with the Graphics Layer or you need to override the mouse events such as ... or any combination of the events that are available.

onMouseOut(event)
onMouseOver(event)
etc..

Though you would think that the disableMouseEvents() should work to solve this issue (as you stated). 

For testing purposes. Try not setting an InfoTemplate or map.InfoWindow on your graphic layer and disableMouseEvents() and see if this fixes the weird issue that you are seeing. If so, then maybe what you need to do is figure out the event that ESRI turns on and use the dojo.disconnect(myEvent) to turn it off.  Maybe someone from ESRI can help point you in the right direction.

Good luck and hope you find a solution to your problem.
0 Kudos
JavierAbadía_Miranda
New Contributor
Did you manage to solve this issue?

I have the same exact need: create a graphics layer that is completely transparent to mouse events, but lets other graphic layers to receive clicks and drags.

Any clues?
0 Kudos
AndyGup
Esri Regular Contributor
One way to make mouse clicks on Graphics transparent is to set CSS pointer-events to none. How this all works depends on why type of Graphics you are using in your different layers.

If your top most layer happens to be using ArcGIS SimpleMarkerSymbol, SimpleLineSymbol and SimpleFileSymbol and your secondary layer is some other type of Graphic then you may be in luck. Adding one of these graphic types to the map creates an SVG image. So, in that case you could try something like this:

Example:

- Layer 1: SimpleMarkerSymbol and SimpleFillSymbol which use <circle> and <path>
- Layer 2: Picture Marker Symbols using <image>

      
 <style>
        circle {
            pointer-events: none;
        }
        path{
            pointer-events: none;
        }
 </style>


References:
http://caniuse.com/#search=pointer-events

https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events


[ATTACH=CONFIG]31886[/ATTACH]
0 Kudos
JavierAbadía_Miranda
New Contributor
Thanks Andy,

That's absolutely right. I ended up setting a "pointer-events:none" style to each of the graphics in the layer.

domStyle.set(graphic.getNode(), "pointer-events","none");

Thanks!
0 Kudos