Forum Discussion
Phone Keypad Simulator
I'd like to simulate a phone keypad on a slide, so that when a user presses numbers they appear on the screen, as if dialling.
It's to help people learn the emergency services numbers for different countries.
Any ideas welcomed :)
- PhilMayorSuper Hero
You could do with one target variable and set each button to multiply the number by 10 and the add the value of the button e.g.
Press button 1 mutiply var by 10 and add 1
etc only issue is you cannot start with a 0
- JudyNolletSuper Hero
Easy enough to create the keypad buttons. There are a few ways you could program them to display the associated number when pressed.
- The numbers could appear via objects that have a state for each number.
- Or the numbers could be put into variables that are referenced in text boxes.
The complicated part is that you have to track which object/field to put each number into as subsequent buttons are pressed. For that, you need to use variables and triggers with conditions. (Lots of triggers...)
The attached file demonstrates putting the numbers into variables, and then displaying those variables.
- A number variable will always show whatever the default value is, which would be confusing. So I put the numbers into text variables (N1, N2, and N3). That lets the initial display be blank. (Note: If these numbers needed to be used in math operations, they would need to be in number variables.)
- There is a number variable (N_current) to track the number of presses. That has a default value of 1.
In the demo, only button 1 has the triggers, and only 3 entries are allowed. Here's what those button triggers look like:
- Note that the trigger to add 1 to N_current must come after the triggers that set the N# variable.
- The same set of triggers could be copied and pasted to other number buttons. Then just edit each of the first three triggers to set the value to the corresponding number.
I also programmed the hashtag button to reset everything.
- GrahamDWoodsCommunity Member
Wow, this is so incredibly helpful! Thank you very much.