|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| How do I change the contents of a textbox with the click of a button? | |||||||||||||||||||||||||
|
There are two ways to change the contents of a textbox with commands. (Let's assume that the textbox is named text1 and the words "This is the new text" stand for the new contents of the textbox.)
Either method has the same effect: replacing the contents of the textbox with the words inside the brackets. When the command(s) are placed in a procedure, they can be activated by a button. One button can also be used to call a different procedure with each click, so that a whole story can unfold on one page. In this demo, each procedure triggers a small animation along with the new text.
Notes: Each procedure for changing the text uses the same base name but ends with a different number. The procedures are numbered in order. The next procedure uses word to combine the base name with the value of the variable newtext. It runs the procedure with this name and then increases newtext by 1, so when the next button is clicked again, it will call the procedure ending with the next number. The last procedure in the story sets newtext to -1, and the newtext procedure immediately increases this number by 1, so that the next click of the button calls the procedure ending with 0. By the way, Ralph can erase the trees without also cleaning the landscape because freezebg was used to freeze the background right after it was drawn. |
|||||||||||||||||||||||||
|