PasswordTextBox: enter a password

169 views
Skip to first unread message

Scott Ferguson

unread,
Dec 14, 2012, 10:34:57 AM12/14/12
to
The PasswordTextBox component can be used to load features or data specific to the user or to lock portions of an app from use by unauthorized users.

In this exercise we will make a simple project to accept a password from the user then display a message based on that input.

Create a new project named lrn_pwd_login .

Screen Designer:

Change the Screen1.Title to Enter your password














Drag and drop a PasswordTextBox component to the Viewer.















Drag and drop a Button component in the Viewer.
Change the Button1.Text to Submit












Blocks Editor:

Drag and drop a Button1.Click block.



Drag and drop an ifelse block inside the Button1.Click block.
 - this will be used to decide what to do depending on what is entered as the password.









Drag and click a math = block to the ifelse test socket.
 - this will be used to compare the contents of the PasswordTextBox to the correct password.












Drag and click a PasswordTextBox1.Text block to the left side socket of the math = block.











Drag and click a text block to the right side socket of the math = block.
Change the text to the password secret .
 - If the correct password of secret is entered into the PasswordTextBox, then any blocks in the then-do section of the ifelse block will be executed.
 - If any other text is entered, the else-do section will execute it's blocks.






Drag and drop Screen1.Title blocks inside the then-do and else-do parts of the ifelse block.












Drag and click text blocks to each of the Screen1.Title to sockets.
Change the text of the first one to Login succeeded!
Change the text of the second one to Intruder alert!!!!
 - these new blocks determine what is displayed in the Screen1.Title bar.



Now test your project in the emulator or connected device.
Enter some text into the PasswordTextBox then press the Submit button.
 - if secret was entered for the password, the following message should display. Any other text entered should display the warning message.



END.

Challenge: Assume that the app is being used by members of a family of 4. If one of 4 correct passwords is entered, display a special greeting for that family member.

 If an incorrect password is entered, display 'invalid password'. 

For example, if 'shazam' is entered as the password, display 'Welcome back, Billy!'  If an incorrect password is entered, display 'invalid password'.


lrn_pwd_login.zip
Reply all
Reply to author
Forward
0 new messages