Step 4: Changing the Selection
To change the selection, we simply add to or subtract from the Selection value.Horizontal movement is simple. Pressing Left will subtract 1 and pressing Right will add 1. Vertical movement depends on the Keypad width. Our keypad is 10 characters wide, so we must add 10 when the user pressed Down and subtract 10 when the user presses Up.
- Upon pressing "Left Arrow"
: Sub 1 from Selection
: Play sample menu_click
- Upon pressing "Right Arrow"
: Add 1 to Selection
: Play sample menu_click
- Upon pressing "Up Arrow"
: Sub 10 from Selection
: Play sample menu_click
- Upon pressing "Down Arrow"
: Add 10 to Selection
: Play sample menu_click
Now, if you test your application, you will notice that scrolling off the keypad will set Selection to a value outside 0 and 39 and no character is selected. To "wrap" the keypad, add the following events:
- Current Selection of
< 0
: Add 40 to Current Selection
- Current Selection of
> 39
: Subract 40 from Current Selection

7