🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #16676

Re: Catching all keyDown events in a DA

#16676
From: Ed Tecot
Date: Mon, 08 Jun 1987 23:15
36 lines
2313 bytes
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
Technical Details
Message-ID: <964@apple.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!ut-sally!husc6!sri-unix!ctnews!pyramid!voder!apple!tecot
References: <164500033@uiucdcsb>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!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