Path: utzoo!attcan!uunet!portal!cup.portal.com!nicky From: nicky@cup.portal.com (nick john pilch) Newsgroups: comp.sys.mac.programmer Subject: Modal dialog filter proc Message-ID: <18219@cup.portal.com> Date: 11 May 89 02:17:42 GMT Organization: The Portal System (TM) Lines: 51 Below is the code for a modal dialog filter proc that seems to have a problem. The relevant part of this function draws a border around the default button whenever the dialog gets an update event. It then returns FALSE to signal Modal Dialog to handle the update event also (draw the rest of the dialog). The problem is that sometimes the dialog keeps getting update events until doomsday. My filter proc then proceeds to keep drawing the border over and over again. Anyone have any clues? A related problem is that I have a check box in this dialog that, when hit, will cause ModalDialog to return (as it is an enabled item). However, the event does not seem to get consumed as then ModalDialog keeps returning the same event and the same itemHit over and over again til doomsday or another event occurs. (It's really humorous since my code will then keep checking and unchecking the checkbox very rapidly.) MPW C 3.0 #define DEFAULT_ITEM_NO 1 void drawDefaultButtonRect(Rect* pItemRect); pascal Boolean OKDialogHook(DialogPtr pDialog, EventRecord* pEventRec, short* pItemHit) { short kind; Handle itemHandle; Rect itemRect; GrafPtr pSavePort switch(pEventRec->what) { case updateEvt: // HILITE DEFAULT BUTTON GetDItem(pDialog, DEFAULT_ITEM_NO, &kind ,&itemHandle, &itemRect); GetPort(&pSavePort); SetPort(pDialog); drawDefaultButtonRect(&itemRect); SetPort(pSavePort); return(FALSE); break; case keyDown: // STUFF FOR KEYDOWN DELETED return(FALSE); break; default: return(FALSE); break; } }