How do you change a right-click into a double-click?

I have a playground where, if you right-click on the red roof area, a sphere will appear. Select it (left click… the gizmo appears) then click the blue Ch.1 button below. The sphere’s colour will change to blue. Right-click on the roof space again…this time use the Ch.2 button to make the new sphere orange in the same way as before.

In the end, several spheres of different colours can be dotted about the roof area. And any sphere should be able to be deleted if needed.

At the moment, I have a right-click to create a sphere, I would really like this to be double-click instead. I have tried to figure this out with no luck. Can anyone help me change this to a double-click action?
The existing code is at line 43.

Thanks for you help.

Hey @Bov

Here’s a great playground example from @Deltakosh that shows how to use doubletap in your scene.

https://www.babylonjs-playground.com/#1GLEJK#5

If you note in the function that’s added to the scene.onPointerObservable, there’s a case that handles doubleTap. You can use this as reference.

Here’s a small playground that isolates it further. If you double-click in the scene, you’ll see a log of the doubleclick event in the console.

https://www.babylonjs-playground.com/#1GLEJK#9

Hope this is helpful!

1 Like

Hi PirateJC, thanks for this.

I am looking for a double click as a way for my project to work on an iPad. The more I have tried to get the double click function to work the more I think it’s not going to. I just couldn’t find the right spot to add the new code for my project for everything to work properly – this is probably due to not programming the surrounding code well. And I am also wondering if double tapping on an iPad is going to result in a sore finger.

Thanks again…sadly I think I am going to leave my project as is.

Are swipes something Babylon.js can do? A small side swipe maybe better than a double click.

Cheers.

Hey Bov.

The “double click” action is also a double tap action. In fact Babylon treats clicks and taps the same. So an ipad application can definitely technically work using this double tap/click method.

Now that said, if the User Experience isn’t right for your particular application, then that’s a completely different story.

You can absolutely program swipes into your Babylon.js application using the Pointer Move event type. Interacting With Scenes | Babylon.js Documentation

You’ll have to come up with your own logic to as to what initiates a “Swipe,” (for example moving the pointer in a negative or positive x direction over a certain time period) but the technology is definitely there for you.

Hope this helps!