Reply To: Track Mouse Position

PennController for IBEX Forums Requests Track Mouse Position Reply To: Track Mouse Position

#5433
irenecg
Participant

Hi Jeremy,

It’s me again. Sorry to come back to this message, but we realized we really need to track cursor position upon click. Our problem is that we need to record many clicks in the same trial, and, as far as we have seen, we are unable to record this into one variable AND log it for different values.

Let me explain: We have an experiment in which subjects have to click at different parts of the screen within the same trial. Ideally, these parts would be 2, but our subjects are children, so it is very possible that they click more than once, twice and even 10 different times to different parts of the screen (and we cannot predict where nor how many times). In that case, we would like to have the coordinates of the mouse for each of their clicks.
We tried:

newVar("mousex"),newVar("mousey")
,
newMouseTracker("mouse")
    .callback( (x,y) => [getVar("mousex").set(x)._runPromises(),getVar("mousey").set(y)._runPromises()] )
    .start()
,
newCanvas( "wholescreen" , "90vw" , "90vh" ).print( "top at 0" , "left at 0" )
,
newSelector().add( getCanvas("wholescreen") )
.callback(getVar('mousex').log(), getVar('mousex').log())
.log(all)
,
newButton('go!')
.size("10vw", "10vh")
.print("left at 90vw","top at 90vh")
.wait()