Only left click on PointerDragBehavior

Hello !
I’m currently using the PointerDragBehavior and I start the drag “manually” in the code with the function behavior.startDrag() and stops the drag by left-clicking with some other interactions behind on left-click. However releaseDrag() is also called when I do a right-click or a wheel-click and I don’t want it to happens especially that the wheel and the right click are used for the camera only in my case.

I tried to hard code the behavior observer however the first callback seems to be called each time I right click :


behavior.releaseDrag = () => {console.log("hello world");} // Just a test to see if releaseDrag is called
behavior._scene.onPointerObservable._remove(behavior._pointerObserver);
behavior._pointerObserver = null;

After that, on right click releaseDrag() is still called by logging hello world and I really don’t know why and how to block it.

Any help or advice ?

Pinging @trevordev

Will this PR fix your issue?

If that is merged this playground should work Babylon.js Playground which will make mouse not automatically start/release dragging and you can do it manually however you want.

3 Likes

Seems to be a great solution ! Thanks for helping !