ScreenSpaceEventType right double click not working

Hi Cesium Team,

I have a requirement to use mouse right double click.. used the following code to get it.. but its not getting fired.

var viewer = new Cesium.Viewer('cesiumContainer');
var scene = viewer.scene;
var mouseHandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
mouseHandler.setInputAction( function(movement){
     console.log('right double click');
                    },Cesium.ScreenSpaceEventType.RIGHT_DOUBLE_CLICK);

Please help me on this.

Thanks,
Raghu.

It looks like RIGHT_DOUBLE_CLICK has never worked. This is because the browser is never actually sending the double click event, so Cesium has no way to know it happened. A quick search looks like this is an issue in all browsers (and not just with Cesium).

I would recommend just implementing a right double click even yourself, using standard browser events. Listen for the right single click events and compare the time between 2 right clicks to detect double clicks.

I’ll write up an issue so we can look at this in Cesium, but we’ve also talked about deprecating ScreenSpaceEventHandler completely and telling everyone to just use standard browser events.

Thanks Matthew for your reply. Will try your suggestion. And one question from your answer.
"about deprecating ScreenSpaceEventHandler completely and telling everyone to just use standard browser events."

As we used ScreenSpaceEventHandler in many cases.. so if it deprecates what would be the alternative for this..? and if we use standard browser events how do we get picked objects ..?

var mouseHandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
mouseHandler.setInputAction( function(movement){
     var pickedObject = scene.pick(movement.position); // can i get this 'position' from standared event object..?
},Cesium.ScreenSpaceEventType.LEFT_CLICK);

The standard events do everything you need, so your code would just be written as:

scene.canvas.addEventListener(‘click’, function(e){

var pickedObject = scene.pick(new Cesium.Cartesian2(e.clientX, e.clientY));

}, false);

That being said, the best solution for an application is to probably use something like jQuery Ponter Events Polyfill which will give you a unified interface that will work across all input types and devices. The only reason Cesium doesn’t do this is because we can’t do anything that will alter the global scope.

Thanks Matthew.. :slight_smile: