question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Window mousedown/mouseup events no longer fire in Chrome

See original GitHub issue

Window 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:closed
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
emackeycommented, Feb 8, 2017

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 mousedown event is obsolete. On browsers supporting pointer events, old-school mousedown is only fired as a fallback for when the real pointer event went unhandled by the page.

The correct solution is to use viewer.screenSpaceEventHandler as 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.

0reactions
mramatocommented, Feb 8, 2017

@emackey while I agree with you, my longer-term goal is actually to make ScreenSpaceEventHandler private because we don’t really want to support it as a general input handler for client apps.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found