Event handler: Reference to mouseX fails

What Wick Editor Version are you using?
1.19.3

Describe the Problem
mouseX normally returns the x-coordinate of your mouse.
so I wrote a bit of code to catch the context menu popup event and read the mouseX, but mouseX is not defined inside of the event handler

What have you tried so far?
I have searched through the forms.
I have tried to store the “path” to mouseX in a variable so I can reference mouseX from within the event handler but I don’t know how to do that (window.mouseX works outside of the event handler code but not inside although the window object exist).

Do you have a Wick Editor File that we can see?
code snippet:
var thisClip=this;
alert(“mouseX:”+window.mouseX); //returns mouseX
debugClip.debugText.setText(“hello before”);
if (document.addEventListener) {
document.addEventListener(‘contextmenu’, function(e) { //or use (e) =>
e.preventDefault();
alert(“mouseX:”+window.mouseX); //fails, returns “undefined”
alert(“mouseX:”+mouseX); //throws Reference error exception

Well there’s a property called this.project._mousePosition. So I guess you can do this instead.

var proj = this.project;

if (document.addEventListener) {
  document.addEventListener("contextmenu", function(e) {
    e.preventDefault();
    alert("x: " + proj._mousePosition.x, "y: " + proj._mousePosition.y);
  });
}

You can’t put this.project inside the event listener function, because then this would refer to the document instead of the clip/frame.

Thank you for this tip!
I was trying e.clientX but that is the coordinate relative to the topleft of the browser window (I guess).
You saved me a lot of haedaches converting this to clip coordinates (it looks like project._mousePosition is relative to the crosshair of the clip wich is more usable)

mouseX and mouseY seem to be variables that are only temporarily available in the Wick editor Mouseclick handler. Once the handler is done they are deleted so it seems…