Hello everyone! How do I prevent triggering the click event on a particular layer when it is sitting behind another layer? Currently I can trigger a click event on a button when it is actually sitting behind everything...
Hi there's probably a better way but the first thing that comes to mind is setting the layer's CSS to pointer-events: none
Layer.style "pointer-events": "none"
(And that second line should be indented.)
Thanks Ces Cortez! I tinkered more with it and found a solution (not sure if it's the right way), but what I did was just set a blank on click function on the layer that's sitting on top.
And make sure the layer index are also correct.
This did the trick for me
Ces Cortez I'll give your solution a try as well, cheers for the quick response!
Jacky, that's how I would do it as well.
Layers without any event handlers attached have pointer-events set to none by default, which is why you're able to click the button through other layers. You can change that by setting this property:
layerOnTop.ignoreEvents = false
This is really the property that gets set when you set the blank click handler, so you might as well use it directly.