PennController for IBEX › Forums › Requests › Track Mouse Position › Reply To: Track Mouse Position
Hi Irene,
You will need a slightly different approach. Here is what I suggest: whenever there is a click (as captured by the Selector’s callback command) you append to two other Var elements the current values of the mousex/mousey Var elements (which are reset whenever the mouse moves, thanks to the MouseTracker’s callback command). Then you log the values of those two Var elements as a string of coordinates separated by periods (or any character for the matter, except a comma which is already used to separate fields in the CSV results file).
newTrial( newVar("mousex"),newVar("mousey"), newVar("clickx",[]),newVar("clicky",[]) , newMouseTracker("mouse") .callback( (x,y) => [getVar("mousex").set(x)._runPromises(),getVar("mousey").set(y)._runPromises()]) .start() , newCanvas("screen", "90vw","90vh").print("left at 0","top at 0"), newSelector().add(getCanvas("screen")).callback( getVar("clickx").set(v=>[...v,getVar("mousex").value]), getVar("clicky").set(v=>[...v,getVar("mousey").value]) ) , newButton('go!') .size("10vw", "10vh") .print("left at 90vw","top at 90vh") .wait() , getMouseTracker("mouse").stop() , getVar("clickx").log().set(v=>v.join('.')), getVar("clicky").log().set(v=>v.join('.')) )
Here’s an example of the two result lines that you get (I clicked three times, hence the three period-separated values):
1590592091,MD5HASHEDIP,PennController,0,0,unlabeled,NULL,Var,clickx,Final,149.576.632,1590592074542,Value at the end of the trial 1590592091,MD5HASHEDIP,PennController,0,0,unlabeled,NULL,Var,clicky,Final,276.329.321,1590592074542,Value at the end of the trial
Jeremy