PennController for IBEX › Forums › Support › disable a button after selection
- This topic has 2 replies, 2 voices, and was last updated 4 years, 10 months ago by
Avery.
-
AuthorPosts
-
April 10, 2020 at 3:27 pm #5031
Avery
ParticipantHello again,
I have one last question! I’m trying to design a section at the beginning of the experiment in which, if the participant chooses a certain response, they cannot continue on to the experiment proper. Basically, I have two buttons, “yes” and “no”, and if they choose no, I’d like the text to change to “Please close the window” and for it to wait here, with no way to continue.
Here is what I have:
newTrial("NYCheck", newText("q","Are you currently residing in New York State?") .print() , newButton("yes","Yes") , newButton("no","No") .callback( getText("q").text("Thank you. You may now close this window.") ) .wait() , newCanvas(200,100) .add(0,0,getButton("yes")) .add(50,0,getButton("no")) .print() , newSelector("NYChooser") .add( getButton("yes") , getButton("no") ) .log() .once() .wait() )
I could be going about this entirely the wrong way, but it seems that when I test what I have, it launches the experiment with the initial question text (“do you live in NY”); the buttons to choose from do not appear.
Any advice would be welcome, thank you very much in advance!:)
-
This topic was modified 4 years, 10 months ago by
Avery.
April 10, 2020 at 11:17 pm #5033Jeremy
KeymasterHi,
So what happens is that your script first prints your Text element, then creates your two Button elements without printing them, because you don’t call print on them, and then halts on the wait command of your No button. Of course you can never release the wait because the button was never printed to start with so you cannot click on it. What you want instead is something like this:
newTrial("NYCheck", newText("q","Are you currently residing in New York State?") .print() , newCanvas(200, 100) .add( 0 , 0 , newButton("yes","Yes") ) .add( 50 , 0 , newButton("no","No") ) .print() , getButton("no","No") .callback( getText("q").text("Thank you. You may now close this window.") , getButton("no").remove(), getButton("yes").remove() ) , getButton("yes").wait() // will wait forever if button removed )
Jeremy
April 11, 2020 at 1:43 pm #5034Avery
ParticipantThat makes sense–dumb error on my part. Thank you!
-
This topic was modified 4 years, 10 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.