Reply To: disable a button after selection

PennController for IBEX Forums Support disable a button after selection Reply To: disable a button after selection

#5033
Jeremy
Keymaster

Hi,

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