# Brokenness from ScreenSpaceEventHandler changes

**URL:** <https://community.cesium.com/t/brokenness-from-screenspaceeventhandler-changes/1889>\
**Category:** CesiumJS\
**Created:** [January 22, 2015, 6:12am UTC](https://community.cesium.com/t/brokenness-from-screenspaceeventhandler-changes/1889 "2015-01-22T06:12:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [January 22, 2015, 6:12am UTC](https://community.cesium.com/t/brokenness-from-screenspaceeventhandler-changes/1889/1 "2015-01-22T06:12:54Z")

</div>

Hi guys,

I just upgraded [National Map](https://github.com/NICTA/nationalmap) to use the head of master and ran into some problems introduced by pull request [#2408](https://github.com/AnalyticalGraphicsInc/cesium/pull/2408). I submitted a [pull request](https://github.com/AnalyticalGraphicsInc/cesium/pull/2417) to fix one of the problems, but there’s another one that needs some discussion.

The problem is that after upgrading Cesium, dragging things is completely broken on my page. Specifically, dragging sliders doesn’t work and dragging/dropping within the app doesn’t work. Dragging the Cesium globe is fine.

I eventually tracked it down to this line in ScreenSpaceEventHandler:

[https://github.com/AnalyticalGraphicsInc/cesium/blob/2315709e0e07cd0f097b5fecfceace019a4a3581/Source/Core/ScreenSpaceEventHandler.js#L248](https://github.com/AnalyticalGraphicsInc/cesium/blob/2315709e0e07cd0f097b5fecfceace019a4a3581/Source/Core/ScreenSpaceEventHandler.js#L248)

Basically, Cesium is registering a mousemove handler on the document, and then canceling the event if a mouse button is currently held down. That’s reasonable if the button was pressed inside the Cesium canvas, perhaps. But it’s happening no matter where on the page the user pressed down the button.

So I’ve simply removed the preventDefault in my app and life is good, I guess. I’m not sure exactly what that preventDefault is supposed to be preventing. Hover styles from taking effect while dragging the globe?

If we do need the preventDefault, perhaps it should move to CameraEventAggregator? That class is able to distinguish between mousedowns that started inside the Cesium canvas and mousedowns that started elsewhere, unlike ScreenSpaceEventHandler (at least after #2408).

What do you think?

Thanks,

Kevin

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [January 22, 2015, 6:16am UTC](https://community.cesium.com/t/brokenness-from-screenspaceeventhandler-changes/1889/2 "2015-01-22T06:16:53Z")

</div>

By the way, Sandcastle examples in master have the same broken-slider problem I ran into in National Map. This one for example:  
[http://localhost:8080/Apps/Sandcastle/index.html?src=Imagery%20Adjustment.html&label=Showcases](http://localhost:8080/Apps/Sandcastle/index.html?src=Imagery%20Adjustment.html&label=Showcases)

---

<div class="post-metadata">

**Author:** ![Ed\_Mackey](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/ed_mackey/32/2226_2.png) [@Ed\_Mackey](https://community.cesium.com/u/Ed_Mackey)\
**Post date:** [January 22, 2015, 10:44pm UTC](https://community.cesium.com/t/brokenness-from-screenspaceeventhandler-changes/1889/3 "2015-01-22T22:44:57Z")

</div>

I think the preventDefault is supposed to prevent text from getting drag-selected while rotating the globe. But as you said, it should only be prevented if the mousedown really happened inside the canvas itself.

–Ed.

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [January 22, 2015, 10:53pm UTC](https://community.cesium.com/t/brokenness-from-screenspaceeventhandler-changes/1889/4 "2015-01-22T22:53:03Z")

</div>

I just tried it in my app with the hacked-out preventDefault. When I click inside the canvas and then drag outside, no text gets selected. If I start my drag outside the canvas, on the text itself, selection works as you’d expect. This is in Chrome and Firefox, I don’t have a Windows machine handy at the moment to test IE.

So I don’t think the preventDefault is necessary for that…

The app is here if you feel like playing with it:

[http://nationalmap.research.nicta.com.au/demo/](http://nationalmap.research.nicta.com.au/demo/)

Kevin
