MouseEvent using window as source causes unexpected GUI behavior

Not making a GitHub issue because this is more of an open question + my experience.
I’ve found working with PlayCanvas and a separate GUI, if an HTML element is above the canvas, the engine will randomly steal mouse events. Specifically, if I have a scrolling element and the canvas has a mouse wheel listener for zooming, 50% of the time the HTML element will scroll and the other 50% of the time PlayCanvas will zoom in/out.
Looking at how the engine detects mouse events, it looks like it uses the window as a source. For me, the fix was to have the PlayCanvas camera use a custom mouse wheel event listener that listened to the PlayCanvas canvas instead of the whole window. It might make sense updating the engine to always use the canvas, I can’t imagine situations where the engine should be capturing events outside the canvas. For reference this is where the engine uses window for mouse events: Of course, that could potentially break a ton of projects if it doesn’t work as expected.

1 Like

IIRC, the touch events are from the canvas. I do wonder what the original reason was as it has been like that for quite a while now.