411 REFERENCE · Wikibooks
Programming for Palm OS/C/Using custom events
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
define the event
#define echoEvent (firstUserEvent + 0)
typedef struct
{
WChar chr; // just to demonstrate transporting data with an event
}
EchoEvent;
build and enqueue an event
EventType event;
EchoEvent *ee;
// set the type of the event to the custom event type identifier
event.eType = echoEvent;
// interpret the Palm OS event storage area as a custom event
ee = (EchoEvent *) &event.data.generic;
// fill in the custom event
ee->chr = chr;
// place the filled out event on the event queue
EvtAddEventToQueue( &event);
handle the event
// as an example of where stock events are handled..
Boolean appHandleEvent( EventPtr event)
...
switch ( event->eType)
{
case keyDownEvent:
...
// custom events are handle naturally alongside stock events:
case echoEvent:
// interpret the Palm OS event storage area as a custom event
EchoEvent *ee = (EchoEvent *) &event->data.generic;
// refer to the parts of the event
ee->chr;