Programming for Palm OS/C/Using custom events
< Programming for Palm OS < Cdefine 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;
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.