Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!ames!uhccux!mikem From: mikem@uhccux.uhcc.hawaii.edu (Mike Morton) Newsgroups: comp.sys.mac.programmer Subject: why does a ModalDialog filter proc get empty update events? Keywords: ModalDialog filterproc update empty Message-ID: <4468@uhccux.uhcc.hawaii.edu> Date: 31 Jul 89 17:42:07 GMT Organization: University of Hawaii Lines: 67 The filterproc passed to ModalDialog sometimes seems to get an endless stream of update events with an empty event region. Anyone know why? This is annoying, because I'd like to use update events to redraw the outline around the default item, making sure that the item reappears if a screen-saver or nested dialog obscures it. I can check for the case where the update region is empty, and avoid doing updating (thus avoiding some cursor flickering) but I'm curious about why these events come in. The code below is a full application which demonstrates the phenomenon. If I take out a NewWindow call (see below), the update events stop. This happens within LSC and as a standalone application, under both Uni- and MultiFinder. System 6.0.3 on an SE/30. -- Mike Morton // P.O. Box 11378, Honolulu, HI 96828, (808) 676-6966 HST Internet: mikem@uhccux.uhcc.hawaii.edu (anagrams): Mr. Machine Tool; Ethical Mormon; Chosen Immortal; etc. ---------------------------------------------------------------------- /* The project contains: MacTraps, sprintf, strings, this file. The project's resource file contains a single DLOG and DITL, both ID #128. DLOG info: bounds (100,100,200,200); procID 1; itemsID 128; visible) DITL info: one item; button, text "OK", enabled, bounds (32,24,48,80) */ pascal Boolean dlStdFilter (DialogPtr theDialog, EventRecord *evt, short *item); void main () { Rect bounds; WindowRecord wind; DialogPtr theDialog; short itemHit; SetApplLimit (CurStackBase - 32000L); MaxApplZone (); MoreMasters (); InitGraf (&thePort); InitFonts (); FlushEvents (everyEvent, 0); InitWindows (); InitMenus (); TEInit (); InitDialogs (0L); InitCursor (); SetRect (& bounds, 32, 32, 64, 64); #if 1 /* commenting the next line out fixes the bug! */ NewWindow (& wind, & bounds, "\p", true, altDBoxProc, -1L, false, 0L); #endif theDialog = GetNewDialog (128, 0L, -1L); SetPort (theDialog); /* not sure this is necessary */ ShowWindow (theDialog); ModalDialog (dlStdFilter, & itemHit); /* await item hit */ DisposDialog (theDialog); /* chuck the dialog's record */ } /* end of main () */ pascal Boolean dlStdFilter (theDialog, evt, item) DialogPtr theDialog; EventRecord *evt; short *item; { RgnHandle upd; if (evt->what == updateEvt) /* anything being updated? */ { upd = ((WindowPeek) theDialog) -> updateRgn; if (! upd) DebugStr ("\p update event with no handle"); else if (EmptyRgn (upd)) DebugStr ("\p empty update"); else DebugStr ("\p real update"); } /* end of handling update event */ return false; } /* end of dlStdFilter () */