eyetracker.callback

getEyeTracker(id).callback( function ) (since PennController 1.8)

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

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.

Example:

[js highlight=”13″ try=”data”]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 at ${this.id} (${x},${y})`)._runPromises(); })
.start()
,
newSelector().add( getText(“Left”) , getText(“Right”) ).wait()
)[/js]

Will display the name of the element being looked-at, along with the X and Y coordinates.

Published by Jeremy

Researcher in semantics and pragmatics; Programmer of PennController for IBEX