Disable right click zoom

836 views
Skip to first unread message

smil...@gmail.com

unread,
Sep 15, 2015, 3:01:38 AM9/15/15
to cesium-dev
I am trying to make a simple context menu to be used when you right click in Cesium and wish to disable the right click zoom (but keep mouse wheel zoom). How would I go about this?

The following appear to have no effect:

viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK);
viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_DOWN);
viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_UP);

Matthew Amato

unread,
Sep 15, 2015, 9:58:58 PM9/15/15
to cesiu...@googlegroups.com
I've noticed this before but we apparently don't have an issue on it.  The only way to disable zoom right now would be with the following line of code.

        viewer.scene.screenSpaceCameraController.enableZoom = false;

I agree with you that instead of this separate variable, the default screen space event handlers should just expose the mapping.  I'll write up an issue on this so we revisit it in the future.



--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

smil...@gmail.com

unread,
Sep 16, 2015, 12:26:18 AM9/16/15
to cesium-dev
Dang, so it's basically all or nothing then? I can't keep mouse wheel and lose the right click zoom?

Matthew Amato

unread,
Sep 16, 2015, 9:04:45 AM9/16/15
to cesiu...@googlegroups.com
Give this a try:

var screenSpaceEventHandler = viewer.screenSpaceEventHandler;
screenSpaceEventHandler.setInputAction(function(){
    viewer.scene.screenSpaceCameraController.enableZoom = false;
}, Cesium.ScreenSpaceEventType.RIGHT_DOWN);

screenSpaceEventHandler.setInputAction(function(){
    viewer.scene.screenSpaceCameraController.enableZoom = true;
}, Cesium.ScreenSpaceEventType.RIGHT_UP);

Daniel Bagnell

unread,
Sep 16, 2015, 9:29:09 AM9/16/15
to cesium-dev
The screenSpaceEventHandler does expose the mappings on the zoomEventTypes property. The default is [CameraEventType.RIGHT_DRAG, CameraEventType.WHEEL, CameraEventType.PINCH]. You can set it to an array without CameraEventType.RIGHT_DRAG or, if you aren't using, a touch interface, use:

viewer.screenSpaceEventHandler.zoomEventTypes = CameraEventType.WHEEL;

Matthew Amato

unread,
Sep 16, 2015, 9:46:12 AM9/16/15
to cesiu...@googlegroups.com
Thanks Dan, I had no idea that existed.  The property is actually on the controller, not the handler.  So the final code would be:

viewer.scene.screenSpaceCameraController.zoomEventTypes = Cesium.CameraEventType.WHEEL;

smil...@gmail.com

unread,
Sep 16, 2015, 10:15:47 AM9/16/15
to cesium-dev
Legendary, thanks guys!

That does exactly what I wanted.
Reply all
Reply to author
Forward
0 new messages