PointerEventTypes POINTERTAP without small movements

hey there,
i am building a small draw tool but struggle with the pointerEventTypes. According to the manual POINTERTAP only fires when there was no movement between pointerdown and -up. BUT in reality i can click, then slightly move the mouse and release the click – and it still will be registered as a POINTERTAP.
is there anything like a threshold to prevent this behavior?

Thank you so much,

Pcace

1 Like

cc @PolygonalSun

Try to tune DragMovementThreshold on the InputManager class InputManager | Babylon.js Documentation

It’s not readonly so probably you can change it.

UPD: And I found this property on the scene, interesting! Scene | Babylon.js Documentation

1 Like

Hi @pcace just checking in if you need any more help with this?

Hi there, i am currently measuring the time between POINTERDOWN and POINTERTAP - so that i can check for doubleclicks:

  useEffect(() => {
    let downTime = 0
    let upTime = 0
    if (scene) {
      const obs = scene?.onPointerObservable.add(pointerInfoEvent => {
        switch (pointerInfoEvent.type) {
          case PointerEventTypes.POINTERDOWN:
            downTime = new Date().getTime()
            pointerDown(scene)
            break
          case PointerEventTypes.POINTERTAP:
            upTime = new Date().getTime()
            pointerClick(scene, upTime - downTime)
            break
        }
      })
      return () => {
        scene.onPointerObservable.remove(obs)
      }
    }
  }, [scene])
  return <Draw />
}

Maybe that helps someone.

Cheers

2 Likes

With onPointerObservable, we actually have a type for double-click (BABYLON.PointerEventTypes.DOUBLETAP) that uses BABYLON.Scene.DoubleClickDelay as the value to measure between clicks. It works similarly to the code that you have above. If you’re trying to do something specificially against a DOUBLETAP, you could use something like:

scene?.onPointerObservable.add(pointerInfoEvent => {
    // Do something on double-click
}, BABYLON.PointerEventTypes.DOUBLETAP);
2 Likes