nicky@cup.portal.com (nick john pilch) (05/11/89)
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; } }
nicky@cup.portal.com (nick john pilch) (05/11/89)
Sorry for the missing signature Nick Pilch Mountain Lake Software nicky@cup.portal.com AppleLink: D1036
jkjl@munnari.oz (John Lim) (05/12/89)
In article <18219@cup.portal.com> nicky@cup.portal.com (nick john pilch) writes:
-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
HA ! A very common mistake to make ( i used to make it myself until i
got smarter :-)
You are not clearing the updateRgn of your window.
Try returning TRUE on updateEvents OR use BeginUpdate and EndUpdate
in your filterProc.