RolandCsibrei / babylonjs-hammerjs-arc-rotate-camera

5 stars 1 forks source link

Recognize Middle and Right Clicks #3

Open rdurnin opened 2 years ago

rdurnin commented 2 years ago

Pardon me if this is more an issue with hammerjs, but is there a way to have the mouse input accept middle and right click inputs?

RolandCsibrei commented 2 years ago

Hey! HammerJS is intended to handle touch events however a quick search on Stackoverflow offers a solution to your problem: https://stackoverflow.com/questions/27609969/how-to-enable-right-click-and-middle-click-of-mouse-in-hammer-js

rdurnin commented 2 years ago

Hey, and I found that link as well, but it requires editing the npm package contents and isn't ideal. The hammerjs package also seems to override Babylon.js context menu prevention, so I'm not sure it will allow me to easily add m & r mouse click functionality. Perhaps an easier strategy would be to leave the left mouse button functionality with hammerjs and build a second ICameraInput to handle the other two mouse buttons.

RolandCsibrei commented 2 years ago

I don't think you need to edit the NPM package. You just have to put the code from StackOverflow somewhere in your startup code. However the question is what would you like to achieve?

rdurnin commented 2 years ago

Thanks, and I was able use that code to extend the hammerjs behaviour. I am still having issues with the context menu popping up though (right-click), despite setting the following in the camera input constructor:

scene.preventDefaultOnPointerDown = true; scene.preventDefaultOnPointerUp = true;

Do you know how I can suppress the menu when I use right-click? There is a mention of noPreventDefault in the source, but I have seen no change from modifying the value.

RolandCsibrei commented 2 years ago

The easy way to do so is:

 <body oncontextmenu="return false">