Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uflorida!haven!uvaarpa!hudson!astsun7.astro.Virginia.EDU!cak3g From: cak3g@astsun7.astro.Virginia.EDU (Colin Klipsch) Newsgroups: comp.sys.mac.programmer Subject: Re: Help! Keywords: jGNEFilter, GetNextEvent, events Message-ID: <2735@hudson.acc.virginia.edu> Date: 20 Mar 90 20:51:12 GMT References: <45183.25FD20CE@cmhgate.FIDONET.ORG> <25ff4e70.643e@polyslo.CalPoly.EDU> <14463@reed.UUCP> Sender: news@hudson.acc.virginia.edu Reply-To: cak3g@astsun7.astro.Virginia.EDU (Colin Klipsch) Organization: University of Virginia Lines: 71 In article <14463@reed.UUCP> chaffee@reed.UUCP (Alex Chaffee) writes: >In article <25ff4e70.643e@polyslo.CalPoly.EDU> rcfische@polyslo.CalPoly.EDU > >A small suggestion - rather than patching GetNextEvent, take advantage of >the low-memory global jGNEFilter, which is sort of a built-in tail patch on >GNE. It's documeted in a tech note (I can't remember the number); I could >give you source code if you're interested. > >-- >Alex Chaffee >chaffee@reed.UUCP >Reed College, Portland OR 97202 >____________________ Tech Note #85 talks about jGNEFilter. It is a low-memory global which points to code that will be executed upon every event, after the Mac has done some of its own processing. I used to use this method of event filtering for TappyType, and it worked as follows. . . In your INIT: - Load your event-filter code, presumably stored as another resource, into the system heap. - Make sure it's locked. (i.e. set its resLocked bit beforehand) - Detach it with _DetachResource. - Take the whatever pointer you find in jGNEfilter and store it somewhere safe in your event-filter. - Store the address of your event-filter in jGNEfilter. Now every time an event happens, your event-filter (tucked safely inside the system heap) will be called. Hopefully. In your event-filter: - Upon entry, A1 should point to the event record. Do whatever you want to do with the event. - After you've done your thing, jump to the old value of jGNEfilter that you saved previously. In effect, you are "splicing" your event-filter into the flow of event processing. If everyone were to do the same thing, then many different event filters could co-exist. Two Bad Things: Unfortunately, not everyone plays nicely, and thus it may matter when your INIT runs in relation to others. Secondly, jGNEfilter is a low memory global, and thus it is not guaranteed to be around in the long run. Patching GetNextEvent, as a method of event filtering, won't work except as a tail patch, which is a Thing Not To Be Done. The scheme I use now is head-patching SystemEvent, which also seems to be called after every event. SystemEvent is "guaranteed" to be supported, and you don't have to share a precarious memory global with random strangers. ---------------------------------------------------------------------- "May the forces of evil become confused on the way to your house." -- George Carlin \ / Bemusedly, | DISCLAIMER: Colin Klipsch | This text is actually a horrendously UVA Astronomy Department | garbled excerpt from _Mating_Rituals_ Charlottesville, Virginia | of_West_African_Ostriches_, Vol IV, cak3g@virginia.edu | by Davis & Griffin, 1913, pp. 134-135 ____________________________/ \_______________________________________