Getting the user input
We want users to interact with our mobile apps. This means that we must provide the opportunity for the user to provide input, we must capture that input, and we must process it. This recipe focuses on capturing the user input via the mobile keyboard.
How to do it...
The following steps will help you get the user input:
Create a new main stack.
Drag a new button to the stack's card.
Assign the following code to the new button:
on mouseUp ask "What is your name?" with "Type here" \ titled "getting your input" end mouseUp
Execute the code to see the results.
How it works...
We used the ask
command to provide the prompt (What is your name) and default text (Type here). The results are put into the it
variable. This provides us the opportunity to evaluate and manipulate the user's input. If the user selects the Cancel button, no value is put into the it
variable. You can test this by using the if it is empty
line of code.