Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!wuarchive!husc6!endor!siegel From: siegel@endor.harvard.edu (Rich Siegel) Newsgroups: comp.sys.mac.programmer Subject: Re: best way to detect command-. interrupt? Message-ID: <3506@husc6.harvard.edu> Date: 28 Dec 89 23:02:01 GMT References: <694@nems.dt.navy.mil> <33392@ucbvax.BERKELEY.EDU> <9421@hoptoad.uucp> Sender: news@husc6.harvard.edu Reply-To: siegel@endor.UUCP (Rich Siegel) Organization: Symantec Language Products Group Lines: 54 In article <9421@hoptoad.uucp> tim@hoptoad.UUCP (Tim Maroney) writes: >>The best way is to run your event handler, so that other applications can >>run, and your other windows will update while you are calculating. > >Granted, but you're likely to make a long operation even longer. Also, >the standard event handler is probably not appropriate; you want to mask >out most mouse and keyboard operations. But since you're checking the >keyboard, you have to throw away keyboard events (except Cmd-Period). >This zaps typeahead, which is probably not what people will expect. > >>Assuming you don't wish to do _that_, many people do a GetKeys(), and look >>for the command and period in the resulting binary key map. This technique >>may have internationalization problems, so make sure to put the bits you >>are checking into a resource and let your tech support people know how to >>customize it. > >It's worse than that. You have to call the GetKeys when the user is >depressing the key. This means you'd better be calling it very very >very frequently. Again, your long operation is likely to get longer. > >I'm not really sure that there is any good way, short of patching the >keyboard driver -- and even that would be an application-specific >patch, so if you *are* giving other applications time, it could fail to >be invoked when the actual keypress happens. I suppose you could insert >a front-end to the driver into the unit table, but that seems like a >big mess for such a small operation. You're getting warmer... If you wanted to get *really* skanky, you could bottleneck _PostEvent, and set a global flag subject to whether the event was for a fan-period. This involves saving the application's A5 in a safe place, since _PostEvent can get called at interrupt time, and you will probably need to test KeyMap to look for the Command key... Then in whatever operation you'd want to check, just test your global flag each time through the loop, or at selective points during the computation. It's pretty cheap to do all of this, and can be used in places where you don't want to slow down by calling _GetNextEvent or _GetOSEvent... R. ~~~~~~~~~~~~~~~ Rich Siegel Staff Software Developer Symantec Corporation, Language Products Group Internet: siegel@endor.harvard.edu UUCP: ..harvard!endor!siegel "When someone who makes four hundred and fifty dollars an hour wants to tell you something for free, it's a good idea to listen." ~~~~~~~~~~~~~~~