Listening to mouse clicks but not drags?

I’m using
viewer.canvas.addEventListener('click', function(e){
To listen to left button mouse clicks, but it also fires for drag events. I thought using mouseup instead of click might help but it never fires at all.

What’s the best way to listen to non-drag left mouse clicks? Thanks in advance.

Hi, You can use ScreenSpaceEventHandler.

var handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
handler.setInputAction((click) => {
// your code here
}, Cesium.ScreenSpaceEventType.LEFT_DOWN);
  • Regards

Thanks, that’s still firing for drag events. I think I’ll have to listen for mouse up and down, compare the mouse positions to see if it’s a drag or not.

Yeah, That’s a good idea.