Reply To: MouseTracker recording wrong coordinates

PennController for IBEX Forums Support MouseTracker recording wrong coordinates Reply To: MouseTracker recording wrong coordinates


Hi Irene,

I’m sorry for not getting back to your sooner. Unfortunately, I’m still unable to identify the source of your problem. However, I realized something in the meantime, which is that smartphone users typically don’t connect a mouse to their device, but rather directly tap their screen: it makes me wonder how you manage to get coordinates at all for them, given that your script uses a MouseTracker element, which ultimately tracks mouse movements, not clicks (or taps, in the case of smartphones).

To add to the mystery, clientY (which is what the MouseTracker element reports) should never exceed the viewport’s height, which means that investigating possible scrolling-related issues is a dead end anyway.

I apologize for suggesting to use a MouseTracker element to track click coordinates. If you were to re-run your study, I’d now suggest you use a Function element to insert a plain javascript function that will better track clicks, like this:

    newCanvas("content", "50vw","50vh")
        .css("background-color", "orange")
        .print("center at 50vw", "middle at 50vh")
    newFunction( ()=>$(".PennController-content").click( e=>{
       getVar("clickx").set( v=>[...v,e.clientX] )._runPromises();
       getVar("clicky").set( v=>[...v,e.clientY] )._runPromises();
    }) ).call()
    getVar("clickx").set( v=>v.join('.') ),
    getVar("clicky").set( v=>v.join('.') )

Let me know if you make any progress on this issue, I’d like to fix any related bugs in PennController to prevent it from happening again in the future