Window mousedown/mouseup events no longer fire in Chrome
See original GitHub issueWindow mousedown/mouseup events no longer fire in Chrome 55. I also tested Canary with the same result.
The events do fire in Firefox.
This is not a new issue in Cesium; I tested Cesium 1.28, 1.25, and 1.20 with the same results.
var viewer = new Cesium.Viewer('cesiumContainer');
window.addEventListener('mousedown',function(e) {
console.log('mouse down');
});
window.addEventListener('mouseup',function(e) {
console.log('mouse up');
});
window.addEventListener('click',function(e) {
console.log('mouse click');
});
viewer.screenSpaceEventHandler.setInputAction(function(e){
//window.addEventListener('mouseup',function(e) {
console.log('Left down');
}, Cesium.ScreenSpaceEventType.LEFT_DOWN);
@emackey any idea? Is this a new Chrome bug? Or a fix to Chrome that revealed a bug in Cesium? Sandcastle specific (I also tested in a new window).
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Chrome mousedown and mouseup events no longer working ...
I'm running Chrome 88 and they definitely haven't removed onmousedown and onmouseup. That would be a really dumb move as it would break...
Read more >126184 - Clicking on scrollbars fire a mousedown event but ...
A mousedown event is fired when the element is clicked, regardless of whether the scrollbar or the element's content is clicked. This enables...
Read more >Element: mouseup event - Web APIs | MDN
The mouseup event is fired at an Element when a button on a pointing device ... mouseup events are the counterpoint to mousedown...
Read more >Handling Events :: Eloquent JavaScript
The "mousedown" and "mouseup" events are similar to "keydown" and "keyup" and fire when the button is pressed and released. These happen on...
Read more >click, mousedown, mouseup, dblclick - Events - QuirksMode
Test IE 5.5 IE 6
On the window No No
On the window Are these events available on the window? Are these events available on...
On...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Chrome added support for pointerevents, which Edge and IE11 already have. I wouldn’t be surprised to see Firefox introduce them as well. We already support pointerevents to be able to support touch (and pen) interactions in IE & Edge, so Cesium listens for and handles the pointerevents.
Unfortunately this means your old
mousedownevent is obsolete. On browsers supporting pointer events, old-schoolmousedownis only fired as a fallback for when the real pointer event went unhandled by the page.The correct solution is to use
viewer.screenSpaceEventHandleras shown at the bottom of the sample code above, since that goes to the trouble of detecting pointer and touch events as well as old mouse events. If you want to use the raw native JavaScript events, your app code will need to have paths to handle at least pointer events and likely touch events as well.The browser is still willing to fire old mousedown events for non-Cesium elements on the page, but only because those elements don’t have pointer event handlers wired up to them. We can’t offer that to apps that want raw mouse interactions on the Cesium canvas itself, since we already made the jump to pointer events.
Long story short: Upgrade your app’s event handling. Use the ScreenSpaceEventHandler or another polyfill, or roll your own event handling that includes pointer events, but don’t just bind to old-school mousedown and expect the Cesium canvas to fire that, it’s obsolete.
@emackey while I agree with you, my longer-term goal is actually to make
ScreenSpaceEventHandlerprivate because we don’t really want to support it as a general input handler for client apps.