Rogier Schaaf wrote:
> 
> The event loop looks something like:
> 
> static void EventLoop(void)
> {
>   short err;
>   int formID;
>   EventType event;
>   do
>   {
>     EvtGetEvent(&event, 200);
>     if (SysHandleEvent(&event))
>       continue;
>     if (MenuHandleEvent(0, &event, &err))
>       continue;
>     if (event.eType == frmLoadEvent)
>     {
>       formID = event.data.frmLoad.formID;
>       form = FrmInitForm(formID);
>       FrmSetActiveForm(form);
>       if (formID == formA)
>         FrmSetEventHandler(form, (FormEventHandlerPtr) HandleFormA);
>       if (formID == formB)
>         FrmSetEventHandler(form, (FormEventHandlerPtr) HandleFormB);
>     }
>     FrmDispatchEvent(&event);
>   } while(event.eType != appStopEvent);
> }
> 
> Does anybody have a clue what I am doing wrong?

Rogier,
   You should only call FrmDispatchEvent if none of the other event
handlers (system, menu, application, etc.) handled the event: e.g.,
   do {
      EvtGetEvent(&event, evtWaitForever);

      if (!SysHandleEvent(&event))
         if (!MenuHandleEvent(NULL, &event, &error))
            if (!AppHandleEvent(&event))
               FrmDispatchEvent(&event); 
   } while (event.eType != appStopEvent);

   In your example a frmLoadEvent will load the form but then call
FrmDispatchEvent(frmLoadEvent), which is something you don't want
to do.

Regards,
Daniel.

Reply via email to