[comp.sys.mac.programmer] Need help w/ Event Manager

al1f+@andrew.cmu.edu (Andy A. Lee) (07/16/89)

Hello,

I am running a small program called EventTutor from the book "Macintosh
Programming Primer" with LightSpeed C 3.01.  This program demonstrates
the Event Manager by continuously displaying event records from
the event queue.  It is great, it displays mouseUp, mouseDown, updateEvt,
keyDown, autoKey, ... all except keyUp.  But looking at the source code,
it should display keyUp:

    switch ( gTheEvent.what )
    {
        ...
        case keyDown:
            DrawEventString( "\pkeyDown" );
            break;
        case keyUp:
            DrawEventString( "\pkeyUp" );
            break;
        case autoKey:
            DrawEventString( "\pautoKey" );
            break;
        ...

Can someone give me some pointers?  I'd appreciate any help.

Andy A. Lee
al1f+@andrew.cmu.edu

P.S. I am using System 6.02 w/ Macintosh II, 5 MB.

keith@Apple.COM (Keith Rollin) (07/18/89)

In article <0Yk12oy00WB6Ek10Zb@andrew.cmu.edu> al1f+@andrew.cmu.edu (Andy A. Lee) writes:
>
>Hello,
>
>I am running a small program called EventTutor from the book "Macintosh
>Programming Primer" with LightSpeed C 3.01.  This program demonstrates
>the Event Manager by continuously displaying event records from
>the event queue.  It is great, it displays mouseUp, mouseDown, updateEvt,
>keyDown, autoKey, ... all except keyUp.  But looking at the source code,
>it should display keyUp:
>
>	[ source code removed ]
>
>Can someone give me some pointers?  I'd appreciate any help.
>

The answer to this can be found on page 70 of Inside Mac II under the descrip-
tion of SetEventMask:

	"...The system event mask is initially set to post all except
	 key-up events."

Hope this helps,

------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc.  ---  Developer Technical Support
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions

al@inebriae.UUCP (Al Evans) (07/18/89)

In article <0Yk12oy00WB6Ek10Zb@andrew.cmu.edu> al1f+@andrew.cmu.edu (Andy A. Lee) writes:
>
>I am running a small program called EventTutor ...[which]... demonstrates
>the Event Manager by continuously displaying event records from
>the event queue.  It is great, it displays mouseUp, mouseDown, updateEvt,
>keyDown, autoKey, ... all except keyUp.  
[source code deleted]

Your problem is that the keyUp event is masked out by default; the
system event mask is intialized at startup to "everyEvent - keyUpMask"
(See IM I-254). I'm not a C person, but in Pascal you would change this
by calling SetEventMask(everyEvent) (IM II-70).
                                          --Al Evans--
-- 
Al Evans    {tndev,texbell,ssbn}!inebriae!al
            al@inebriae.WLK.COM

d88-jwa@nada.kth.se (Jon W{tte) (07/18/89)

In article <0Yk12oy00WB6Ek10Zb@andrew.cmu.edu> al1f+@andrew.cmu.edu (Andy A. Lee) writes:
>I am running a small program called EventTutor from the book "Macintosh
>Programming Primer" with LightSpeed C 3.01.  This program demonstrates

>it should display keyUp:

If you check Inside Macintosh volume I, you'll see that the system event
mask is by default set to mask out keyUp events BEFORE they get posted.
This may be changed with SetEventMask(int mask);
mask should then be everyEvent.

If you consider programming the mac, buy IM vol I, II, IV and V as well
as the technotes (the latter are available in electronic form for free)
and study them. They are a MUST.

Hope this helps,

				h+@nada.kth.se
-- 
 __       Jon W{tte (The dread Smiley Shark) email:h+@nada.kth.se
/  \      (+46 (0) 8 258 268)
   /---   (c) 1989 Yessbox Allright Professional Products Inc. - Y.A.P.P.I.
  /       -- No More --

chaffee@uvm-gen.UUCP (Alex D. Chaffee,231 Votey,,6581273) (07/19/89)

From article <0Yk12oy00WB6Ek10Zb@andrew.cmu.edu>, by al1f+@andrew.cmu.edu (Andy A. Lee):
> I am running a small program called EventTutor from the book "Macintosh
> Programming Primer" with LightSpeed C 3.01.  This program demonstrates
> the Event Manager by continuously displaying event records from
> the event queue.  It is great, it displays mouseUp, mouseDown, updateEvt,
> keyDown, autoKey, ... all except keyUp.  But looking at the source code,
> it should display keyUp:

Inside Mac, vol. I, p.254:  

"	There's also a global _system event mask_ that controls which events
get posted into the event queue.  Only event types corresponding to bits set
in the system event mask are posted; all others are ignored.  When the
system starts up, the system event mask is set to post all except key-up
event - that is, it's initialized to

	everyEvent - keyUpMask

Note:	Key-up events are meaningless for most applications...[You can] set
	the system event mask with... SetEventMask."

> 
> Andy A. Lee
> al1f+@andrew.cmu.edu

Alex Chaffee
chaffee@emily.uvm.edu
____________________________