Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!husc6!sri-unix!ctnews!pyramid!voder!apple!tecot From: tecot@apple.UUCP (Ed Tecot) Newsgroups: comp.sys.mac Subject: Re: Catching all keyDown events in a DA Message-ID: <964@apple.UUCP> Date: Mon, 8-Jun-87 19:15:07 EDT Article-I.D.: apple.964 Posted: Mon Jun 8 19:15:07 1987 Date-Received: Thu, 11-Jun-87 05:44:45 EDT References: <164500033@uiucdcsb> Reply-To: tecot@apple.UUCP (Ed Tecot) Organization: Apple Computer Inc., Cupertino, USA Lines: 36 In article <164500033@uiucdcsb> kkim@uiucdcsb.cs.uiuc.edu writes: > > I am writing a Desk Accessory which transforms every input character. >The transformation is affected by a previous character, a current char, >Caps Lock key, shift key, option key, and command key. My DA does *not >have its own window*; it is running in the *background* and transformed >chars will be passed to an application (e.g. MacWrite). > > My DA is working a little now. The biggest problem is that ONLY SOME >input chars do get transformed; however, there are other input chars which >do not get transformed. I will show you a skeleton of my DA in Lightspeed >Pascal to give you a concrete idea. > >... > > When LIMIT was greater than about 500, some characters were lost if >I typed fast (due to the maximum event queue size). I guess that LIMIT >shoud be set to 1 and some other mechanism must be adopted to get around >the problem. Does Vertical Retrace Manager have anything to do with it? > > > Could anybody give me clues/hints/comments as to how to CATCH ALL THE >KEYDOWN EVENTS IN A DESK ACCESSORY AND TRANSFORM THEM? > Your problem is that keyboard (and mouse) events are asynchronous. It is possible that your DA could check the queue, find no events, only to have a user type immediately after that (and before the application calls GetNextEvent.) I recommend that you catch the events as they are posted. Every event is posted using PostEvent. Simply use GetTrapAddress and SetTrapAddress to insert your code. Remember that you will be called at different interrupt levels and therefore you cannot make calls to the memory manager (even indirectly), and that relocatable segments are not usable. _eme