Line-by-line Anatomy of Hello_a.c (Cont.)


if ( MenuHandleEvent( (void *) 0, &e, &err ) ) continue;
The function Boolean MenuHandleEvent( MenuBarType *menuP, EventType *event, UInt16 *error ) handles events in the current menu. This routine handles two types of events, penDownEvent and keyDownEvent. It returns true if the event is handled; that is, if the event is a penDownEvent within the menu bar or the menu, or the event is a keyDownEvent that the menu supports. Returns false on any other event.

case ctlSelectEvent:
    if ( e.data.ctlSelect.controlID == OK )

The control routine CtlHandleEvent( ) sends this event. When CtlHandleEvent receives a ctlEnterEvent, it tracks the pen until the pen is lifted. If the pen is lifted within the bounds of the same control it went down in, a ctlSelectEvent is added to the event queue; if not, a ctlExitEvent is added to the queue. For this event, its data field contains the structure:
   struct  ctlSelect {
     UInt16  controlID;
     struct  ControlType  *pControl;
     Boolean on;
     UInt8   reserved1;
     UInt16  value;
   }  ctlSelect;
Remember that the data field is part of the access path to an identifier in the EventType structure such as e.data.ctlSelect.controlID .