home | |||
links |
|
||
developer's mag main page article part 1 part 2 part 3 part 4 part 5 part 6 part 7 part 8 |
6 - Displaying The KeyboardsOur sample app also includes a special response to the K_KEYBOARD value, to provide an onscreen keyboard:if ( K_KEYBOARD==data || ( hostIO_is_simulator() && 'k'==data ) ) { static bool inUse=false; if ( ! inUse ) { inUse=true; // lock & prevent second call CLatin1Keyboard *keyboard=new CLatin1Keyboard(99,0); keyboard->SetCurScreen(0); // choose keyboard GUI_EventLoop(keyboard); // display it inUse=false; // unlock } }The first line checks for the keyboard code. As a convenient shortcut in debugging (and because I couldn't find a way to generate the K_KEYBOARD key on the simulator), the code also allows the 'k' character to call it up (using hostIO_is_simulator() to guarantee this shortcut only works on the emulator, and won't interfere with code running on a real ebm). Once we've decided that it's Keyboard Time, we then prepare to display. The inUse static variable is needed because of a bug my code encountered: when I displayed the keyboard with the upward stroke, doing so a second time crashed the program. While unlikely in general use, the extra code makes sure this can't happen, since the inUse variable acts as an access lock to prevent multiple simultaneous calls of the keyboard. Previous Section Next Section |
||
Copyright © 2001-2006 ebmDevMag.com - Legal Notice |