Reply To: Key press highlights wrong image

PennController for IBEX Forums Support Key press highlights wrong image Reply To: Key press highlights wrong image

#7158
Jeremy
Keymaster

Hi Daniela,

Removing the Canvas element from the page does not disable the Selector element: it is still active, even if the elements it contains are not visible on the page

Here’s an edited version of your code. Most of the edits are aesthetic; the crucial bit is the default .once() on the Selector elements, which prevents them from continuing to record keypresses after the initial choice:

Template( 
  GetTable( "stimuli.csv")// change this line for the appropriate experimental list
      .filter("type" , "critical")
      .filter("lifetime" , /^(dead|alive)$/)
  ,
  variable => newTrial( "post_task" ,
    defaultText
        .css({"font-family":"courier","font-size":"25px"})
        .center()
    ,
    defaultSelector
        .once()
        .log()
    ,
    defaultCanvas
        .log()
        .center()
    // NEW TEXT
    ,
    newText("post_name",  variable.name)
    ,
    newText("occupation_correct", variable.occupation)
    ,
    newText("occupation_incorrect", variable.occupation_distractor)
    ,
    newText("nationality_correct",  variable.nationality)
    ,
    newText("nationality_incorrect",  variable.nationality_distractor)
    ,
    newText("lifetime_correct", variable.lifetime)
    ,
    newText("lifetime_incorrect", variable.lifetime_distractor)
    ,
    newImage("checkmark", "https://amor.cms.hu-berlin.de/~pallesid/dfg_pretests/pictures/checkmark.jpeg").size(30,30)
    ,
    newImage("crossmark", "https://amor.cms.hu-berlin.de/~pallesid/dfg_pretests/pictures/crossmark.png").size(30,30)
    ,
    // NAME
    newCanvas("name", "100vw" , "100vh")
        .add("center at 50%", "center at 20%", getText("post_name"))
        .add("center at 25%", "center at 20%", getImage("checkmark") )
        .add("center at 75%", "center at 20%", getImage("crossmark") )
        .print()
    ,
    newSelector("post_name")
        .add(getImage("checkmark"), getImage("crossmark"))
        .keys("F", "J")
        .wait()
    ,
    getCanvas("name").remove()
    ,
    // LIFETIME
    newCanvas("lifetime", "100vw" , "100vh")
        .add( "center at 30%", "center at 20%", getText("lifetime_correct"))
        .add( "center at 70%", "center at 20%", getText("lifetime_incorrect"))
        .print()
    ,
    newSelector("post_lifetime")
        .add(getText("lifetime_correct"), getText("lifetime_incorrect"))
        .shuffle()
        .keys("F", "J")
        .wait()
    ,
    getCanvas("lifetime").remove()
    ,
    // NATIONALITY
    newCanvas("nationality", "100vw" , "100vh")
        .add( "center at 30%", "center at 20%", getText("nationality_correct"))
        .add( "center at 70%", "center at 20%", getText("nationality_incorrect"))
        .print()
    ,
    newSelector("post_nationality")
        .add(getText("nationality_correct"), getText("nationality_incorrect"))
        .shuffle()
        .keys("F", "J")
        .wait()
    ,
    getCanvas("nationality").remove()
    ,
    // OCCUPATIION
    newCanvas("occupation", "100vw" , "100vh")
        .add(  "center at 30%", "center at 20%", getText("occupation_correct"))
        .add("center at 70%", "center at 20%", getText("occupation_incorrect"))
        .print()
    ,
    newSelector("post_occupation")
        .add(getText("occupation_correct"), getText("occupation_incorrect"))
        .shuffle()
        .keys("F", "J")
        .wait()
    ,
    getCanvas("occupation").remove()
    ,
    // WAIT
    newCanvas("dots", "100vw" , "100vh")
        .add("center at 50%", "center at 20%", newText("pleasewait_post2", "...").bold())
        .print()
    ,
    newTimer("wait_post2", 1000)
        .start()
        .wait()
    ,
    getCanvas("dots").remove()
  )
  .log("type", variable.type)
  .log("lifetime" , variable.lifetime)
  .log("tense", variable.tense)
  .log("mm", variable.mm)
  .log("match", variable.match)
  .log("rating", getVar("rating"))
  .log("item" , variable.item_id)
  .log("name" , variable.name)
  .log("list", variable.list)
  .log( "withsquare", GetURLParameter("withsquare") )    
  .log("bare_verb", variable.bare) 
)

Jeremy