Is it possible to get the original DOM event?

I have added an input handler looking for MOUSE_MOVE events. I am getting the events. However, the only information I am receiving is the position of the cursor. I would like to be able to get the original DOM event which trigger the mouse move because I need to check to see if the mouse button is down.

I can use document.body.matches(':active') to test, but this seems like it is overkill when the information is available in the original event.

But, I am not sure how to get to that original event. Is it possible?

Yes, it is possible to access the original event that triggered the mouse move event. When you receive the mouse move event, you can access the original event by using the "event" property of the mouse more event.

I have a sandcastle

I have attached a MOUSE_MOVE input action.

If I am correct, the MOUSE_MOVE input action expects a function that can receive a Cesium.ScreenSpaceEventHandler.MotionEvent. I do not see an event property here and when I try to log an event property, it tells me it is undefined.

Have I missed something? Can you provide a corrected sandcastle?

I am guessing you thought I was referring to Element: mousemove event - Web APIs | MDN, but am not. However, I assume that Cesium is using these Dom events. I just need to be able to get access to the original Dom event. But, I do not see how.

hello every one
i think
To access the original DOM event object in an event handler function, you can use the event parameter that is passed to the function. This parameter is automatically provided by the browser and contains a reference to the Event object.
i hope it will very useful.


As the sandcastle I provided shows, the event parameter passed in does not contain the original DOM event object.

you need to add event listeners to the gl rendering context for the canvas object which holds the cesium instance, not cesium itself. I have an example of handling mouse dragging that can be found here: webGraphicsEngine/mouseControls.ts at main · shanebenlolo/webGraphicsEngine · GitHub

This example concerns itself with rotating a webgl cube, but the core functionality of checking for if a mouse is dragging should satisfy whatever requirements you’re trying to fulfill. Let me know if you have any questions.

@shane_benlolo, thank you. I think I will stick with document.body.matches(':active') for now.

It seems a bit extreme to go down into the webgl layer for this purpose.