How could I click programmatically on a scene an receive a onPointerObservable callback?

Hi,
I would like to test the onPointerObservable that I have written. I would like to send a mouse event in the test to the scene that has an onPointerObservable

I previously was able to track this down for Keyboard events with How could I send a programmatic button click to a scene?

But for mouse events I am missing something. Playground is
https://www.babylonjs-playground.com/#XZ0TH6#52

My goal is to send a mouse event and console log that the event has occurred in the onPointerObservable

Does anyone know how to do this? Thanks

Maybe @PolygonalSun could help for this one.

Hey @kmitov,

On initial inspection, you are triggering an event against “mousedown” rather than “pointerdown”. If you change line 35 to say
clickEvent.initEvent("pointerdown", true, true);
It should trigger your observable properly.

On that note, I feel like it should be triggered on a “mousedown” event so I’ll dig into a bit and verify what’s going on.

3 Likes

Thanks @PolygonalSun. You are right, pointerdown works. It kind of makes sense to work also for mousedown. Hope you could track it down.

1 Like