nicky@cup.portal.com (nick john pilch) (04/03/89)
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