Palm OS/C 编程/使用自定义事件
外观
< Palm OS 编程 | C
#define echoEvent (firstUserEvent + 0)
typedef struct
{
WChar chr; // just to demonstrate transporting data with an event
}
EchoEvent;
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);
// 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;