Link Search Menu Expand Document

eyetracker.callback

description

Tell the script to continuously execute the specified javascript function as long as an element is being looked at.

syntax

getEyeTracker(ELEMENT_NAME).callback(function)
  • function :

notes

  • The function takes is passed two arguments, the estimated X and Y coordinates. The keyword this in the callback function points to the PennElement instance corresponding to the looked-at element.

since

PennController 1.8

example(s)


@newTrial( newButton("Start").print().wait(newEyeTracker().test.ready()) )
@
@newTrial(
@    newEyeTracker("tracker").calibrate(70)
@    ,
@    newText("lookedAt", "").print()
@    ,
@    newText("Left").css("padding","20vw").print("20vw", "40vh"),
@    newText("Right").css("padding","20vw").print("60vw", "40vh")
@    ,
@    getEyeTracker("tracker")
@        .add( getText("Left") , getText("Right") )
$        .callback(function(x,y){ getText("lookedAt")
$                                 .text(`Looking ${this.id} (${x},${y})`)._runPromises(); })
@        .start()
@    ,
@    newSelector().add( getText("Left") , getText("Right") ).wait()
@)
  • Will display the name of the element being looked-at, along with the X and Y coordinates.