Preserve right click context menu with ArcRotateCamera

Hi,

I would like to preserve the context menu with ArcRotateCamera, but even if I use camera.inputs.attached.pointers.buttons = [0] to allow only left click input the right click is disabled and I loose the option to save the canvas as an image.
How can I have the ArcRotateCamera but also the context menu on right click?

Thank a lot.

I think you may use this instruction - Customizing Camera Inputs | Babylon.js Documentation
Also, one may use much simpler draft as here - Babylon.js Playground

Thank you labris.
I already checked the Customizing Camera link you sent me before writing the post but I couldn’t find the solution in there (Maybe I need to write my own Input, but I didn’t really understand how to do it).
The playground you sent me has the same issue I was talking about. What I need is to preserve the original browser context menu behavior and not to implement my own context menu functions. Also in that example the original context menu is gone.

Babylon overrides the context menu event so you can implement it on your own. If you still want it to work, you can override the mouseinput’s onContextMenu function before attaching the camera to the canvas. Something along these lines:

Babylon.js Playground (babylonjs.com)

1 Like

Thanks RaananW, that worked perfectly. You made my day :slight_smile:
Bless

1 Like

I am not able to find contextmenu in arc rotate camera and hence not being able to enable it as shown in the approved solution. Can someone please help?

you should use the pointers input:

camera.inputs.attached['pointers'].onContextMenu = (e) => {
        console.log(e);
    }
1 Like

Exampe - https://playground.babylonjs.com/#PIKP4K#1