Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!portal!cup.portal.com!nicky From: nicky@cup.portal.com (nick john pilch) Newsgroups: comp.sys.mac.programmer Subject: Catching Command-period Message-ID: <16608@cup.portal.com> Date: 3 Apr 89 00:00:26 GMT Organization: The Portal System (TM) Lines: 34 What would people recommend as a method to catch the Command-period signal? I want users to be able to cancel out of a long calculation or something like that. I am using MPW 3.0. I could: 1) Use the Std C Library signal functions. As I understand it, the safe way to use these is to have the signal catching function set a global flag and have the program check this flag when it wanted to. 2) Just write a function such as the one below that uses GetNextEvent and call it when I wanted to (e.g. if (GotCancel()) ...) Sample: #define PERIOD_CHAR 0x2e #define BOOLEAN int BOOLEAN GotCancel(void) { EventRecord theEvent; char theChar; GetNextEvent(keyDownMask, &theEvent); theChar = theEvent.message & charCodeMask; if ((theEvent.modifiers & cmdKey) && (theChar == PERIOD_CHAR)) return(TRUE); return(FALSE); } Thanks for any comments. Nick Pilch Mountain Lake Software nicky@cup.portal.com AppleLink: D1036