Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!apple!keith From: keith@Apple.COM (Keith Rollin) Newsgroups: comp.sys.mac.programmer Subject: Re: WaitNextEvent questions Message-ID: <53029@apple.Apple.COM> Date: 17 May 91 22:03:11 GMT References: <1991May17.044439.25162@schaefer.math.wisc.edu> <1991May17.125352.27138@ux1.cso.uiuc.edu> Organization: Apple Computer Inc., Cupertino, CA Lines: 34 In article <1991May17.125352.27138@ux1.cso.uiuc.edu> dorner@pequod.cso.uiuc.edu (Steve Dorner) writes: >In article <1991May17.044439.25162@schaefer.math.wisc.edu> dickie@schaefer.math.wisc.edu (Garth Dickie) writes: >>Most of the time, the modifiers field seems to be set correctly, but this may >>be an artifact of the previous event. The way I get modifiers now is to call >>GetKeys and look at the right bits. I don't like this much :-) > >I don't blame you. This is what I use: > >/************************************************************************ > * CurrentModifiers - return the current state of the modifers > ************************************************************************/ >short CurrentModifiers(void) >{ > EventRecord theEvent; > > (void) GetNextEvent(nil,&theEvent); > return(theEvent.modifiers); >} Unless the user changes the modifier key state between the time the OS fills in the modifer key field and the time you read it, the event record will always reflect the correct state. Event on null events. Personally, I prefer OSEventAvail() to GetNextEvent() for getting the modifier keys. The Process Manager doesn't get its digs into that call, so you don't have to worry about being swapped out or anything. -- ------------------------------------------------------------------------------ Keith Rollin --- Apple Computer, Inc. INTERNET: keith@apple.com UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith "But where the senses fail us, reason must step in." - Galileo