Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: best way to detect command-. interrupt? Message-ID: <9421@hoptoad.uucp> Date: 28 Dec 89 20:40:20 GMT References: <694@nems.dt.navy.mil> <33392@ucbvax.BERKELEY.EDU> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 40 In article <694@nems.dt.navy.mil> science@nems.dt.navy.mil (Mark Zimmermann) writes: >>What is the 'officially approved' way to sense a command-period >>(cmd-.) so that a user can interrupt a long operation from the keyboard? In article <33392@ucbvax.BERKELEY.EDU> oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster) 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. -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com FROM THE FOOL FILE: "The men promise to provide unconditionally for their wives. The women in turn serve unconditionally to provide the other household services necessary for the men to fulfill their obligations to the women. The women are satisfied because they have the men working for THEM." -- Colin Jenkins, soc.women