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. The menu_click sample is embedded in Enter Name.mfa because it is used in Frame 2, the completed tutorial. Simply click Play Sample and the file will appear in samples the list.

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:
Adding or subtracting the total number of characters in the Keypad will vertically wrap the keypad.

7