0

The Issue:

  • I have two buttons, button "Apple" and button "Cookie".
  • When I press the "Cookie" button, text should show saying "Cookie" on screen (which it does)
  • THEN, when I press the "Apple" button, the text should UPDATE to "Apple" instead of "Cookie"

The problem is, with my current code, whenever I press the second button (Apple) -- the original "Cookie" text isn't removed, it appears underneath the "Apple" text.

I'd like the "Cookie" text to be removed from the screen when I press the apple button or any other button (over 10 buttons)

How would I achieve this within touchdevelop?

Current Code:

http://imgur.com/XAbMeIX


Assistance is very much appreciated.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

0

Try this project: http://tdev.ly/ydcl.

To change what is displayed when a button is clicked, set a global variable and change its value when on tapped is called. In TouchDevelop, the page display is refreshed automatically so that any changes made when a button is tapped will occur immediately. There is no need to hide or show part of the display; just include that section in an if statement and change the if statement condition when a button is tapped. If you wanted to show one of three possible layouts, use an if statement that tests the value of a string or number for one of three values and changes that value when a certain button is tapped or condition is met.

Alekxos
  • 512
  • 6
  • 13