I need to know when the user turns on/off the backlight while my application
is running. According to hardware.h, the virtual key backlightChr is sent
when a change of backlightstate is requested.
I tried to catch this virtual key in my formeventhandler, but I never
recieved it. After a while, i figured out that the event is swallowed by
SysHandleEvent. If I put the call to my virtualkeysHandler in the
AppEventLoop before SysHandleEvent (see code below), I get the
backlightChr-event. I'd rather put the call where it should be, in the
formeventhandler.
What do I need to do to prevent SysHandleEvent from swallowing the
backlightChr-event?
Perhaps KeySetMask is what I need? I havent figured out which argument to
give it though.
/Alex/
---------------------
#define NON_PORTABLE
#include <Hardware.h>
static Boolean virtualKeysHandle(EventPtr eventP) {
Boolean handled = false;
switch (eventP->eType) {
case keyDownEvent:
if ((eventP->data.keyDown.modifiers & commandKeyMask) != 0) {
if (eventP->data.keyDown.chr == backlightChr) {
// do something when user changes state of backlight
handled = true;
}
}
break;
}
return handled;
}
static void AppEventLoop(void)
{
Word error;
EventType event;
do {
EvtGetEvent(&event, 10);
virtualKeysHandle(&event); // hack, to recieve backlightcharacter
if (! SysHandleEvent(&event))
if (! MenuHandleEvent(0, &event, &error))
if (! AppHandleEvent(&event))
FrmDispatchEvent(&event);
} while (event.eType != appStopEvent);
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html.