[comp.sys.mac.programmer] WaitNextEvent questions

dickie@schaefer.math.wisc.edu (Garth Dickie) (05/17/91)

I spent the morning tuning an event loop, and have some questions:

-- Is a 'mouse moved' event supposed to have correct modifier values?  If not,
   what is the best way to get the current modifiers?

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 :-)

-- DA's opened in the application layer appear to only be given time once per
   WaitNextEvent.  With a large delay, they don't get frequent enough accCursor
   control calls, so the cursor becomes outdated.  Do I need to special-case
   (even more than I already do) for a DA in front, and use a small delay?

I think the answer to this one is just 'yes', but would appreciate input...
There is a comment in the Traffic Light 2.0 code that sounds like you have to
use a short delay to get balloon help to work, too.  Is this true?
-- 

Garth Dickie -- Math Graduate Student? -- dickie@math.wisc.edu

dorner@pequod.cso.uiuc.edu (Steve Dorner) (05/17/91)

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);
}
--
Steve Dorner, U of Illinois Computing Services Office
Internet: s-dorner@uiuc.edu  UUCP: uunet!uiucuxc!uiuc.edu!s-dorner

keith@Apple.COM (Keith Rollin) (05/18/91)

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