60 Building applications — Coding an application
Developer’s Guide – RIM 950 Wireless Handheld™
If the user presses a key, the OS sends a MESSAGE to the application from
the KEYPAD device. If we get a KEYPAD message, we pass the MESSAGE to
the UI Engine, which returns a result code:
if( msg.Device == DEVICE_KEYPAD ) {
// Let the UI process the message
result = m_ui_engine.HandleInput( message );
//Process UI Engine result
}
MESSAGEs resulting from a key being pressed on the keyboard are sent
only to the foreground task.
If the UI Engine returns CLICKED, the application should display a
menu. If the UI Engine returns UNHANDLED, the user may have pressed
the BACKSPACE key, in which case we want to return to the main screen
(RIBBON).
if( result == CLICKED ) {
// Set up, display, and handle menu result
}
if( result == UNHANDLED ) {
//Check for the backspace key.
//If the user pressed backspace
//we want to go to the home screen
if( message.Event == KEY_DOWN &&
message.SubMsg == KEY_BACKSPACE ) {
RibbonShowRibbon();
}
}
PagerMain function example
This is a more complicated example of a PagerMain() function; it
includes task yielding, and makes use of items from other DLLs.
#include <Pager.h>
#include <Ribbon.h>
char VersionPtr[] = "Example Application";
int AppStackSize = 4096;
// Function identifying task to the OS
// These values are actually the defaults for
// a PagerMain() thread; see RimCreateThread()
// for more details