Step 11: Coding the Button

Goal:


Let’s start with programming what will happen when we push our button.

Here we can see the power of the TextToSpeech component.

All that we need to do is tell TextToSpeech to speak whatever Text is currently inside the TextBox whenever Button1 is pressed.

Steps:

  1. Under the section labeled Blocks select Button1.
  2. Grab and place the block labeled “when Button1.Click”.
  3. Under Blocks select TextToSpeech1.
  4. Grab and place the block labeled “call TextToSpeech1.Speak”.
  5. Under the section labeled Blocks select TextBox1.
  6. Grab and place the block labeled “TextBox1.BackgroundColor”.
  7. Change “BackgroundColor” to say “Text”.

Code:


Click to replay