Book Image

LiveCode Mobile Development Cookbook

By : Dr. Edward Lavieri
Book Image

LiveCode Mobile Development Cookbook

By: Dr. Edward Lavieri

Overview of this book

Table of Contents (17 chapters)
LiveCode Mobile Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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:

  1. Create a new main stack.

  2. Drag a new button to the stack's card.

  3. Assign the following code to the new button:

    on mouseUp
      ask "What is your name?" with "Type here" \
        titled "getting your input" 
    end mouseUp
  4. 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.