PennController for IBEX › Forums › Support › Feedback after selecting an image › Reply To: Feedback after selecting an image
March 31, 2020 at 12:20 pm
#4951
Jeremy
Keymaster
Hi Elise,
Yes, the logic is exactly the same as with the Key element, you just test for the selected item using .test.selected:
Template( "Filler_orig.csv" , row => ["filler_orig", "DashedSentence", {s: row.Sentence}, "PennController", newTrial( defaultImage .size(400,400) , newImage("CoveredPicture", "covered.jpg") , newImage("VisualPicture", row.Picture) , newCanvas(800,400) .add( -25 , 0 , newCanvas("left" , 400, 400) ) .add( 425 , 0 , newCanvas("right", 400, 400) ) .print() .settings.log() , newCanvas(50,50) .settings.add(-75,-200, newText("(F)")) .settings.add(850,-200, newText("(J)")) .print() , newVar("toggle", 1) // Initialize with value 1 .global().set( v=>1-v ).test.is(1) // This should be 1-v, I think .success( getImage("CoveredPicture").print(0,0,getCanvas("left")), getImage( "VisualPicture").print(0,0,getCanvas("right")) ) .failure( getImage("CoveredPicture").print(0,0,getCanvas("right")), getImage( "VisualPicture").print( 0,0,getCanvas("left") ) ) , newSelector() .settings.disableClicks() .settings.add( getImage("CoveredPicture") , getImage("VisualPicture") ) .settings.keys( "F" , "J" ) .settings.log() .wait() .test.selected( getImage(row.Target) ) .success( newText("Good job!").print() ) .failure( newText("Nope!").print() ) , newButton("Next").print().wait() ) .log('Condition', row.Condition) .log('Item', row.Item) ])
NOTE: I replaced the v-1 bit with 1-v as it makes more sense to me (you want the toggle Var to alternate between 1 and 0, not to tend towards -inifinity)—sorry if that was my mistake from a previous code