Recipe 22.8. Responding to the Soft KeysProblemYou want to respond to the user pressing the phone's soft keys. SolutionUse an offstage button instance to respond to the key press. DiscussionIn the previous section, you learned how to register and relabel the phone's soft keys. After the soft keys have been registered, you can respond to soft key presses. The left and right soft keys are mapped to the same keycodes as the page up and page down keys on a traditional keyboard. Therefore, to detect when the user has pressed the left soft key, you will handle the keyPress event for the <PageUp> keycode. For the right key, you will handle the keyPress event for the <PageDown> keycode. In either case, the convention is to use a button placed offstage in order to handle the events. This method allows you to "listen" for the key presses regardless of whether your user interface calls for an actual button.
|
Tripod >> 3pod Tips & Learning and manuals for educations