[comp.sys.mac.programmer] GetNextEvent at beginning of App

greggor@Apple.COM (Greg L. Anderson) (06/08/91)

In article <25235@well.sf.ca.us> smoke@well.sf.ca.us (Nicholas Jackiw) writes:
>If you're running under Multifinder on 6.x systems (or even if you're not),
>the 10 calls to GetNextEvent() make sure that your window and process
>are brought frontmost--an intermittent problem.

Be careful about doing this on System 7; if your App just blindly calls
GetNextEvent(everyevent) a few times when it starts up, you'll lose all
of your open document high-level events if your app is AppleEvent aware.

If you do call GetNextEvent, at the very least you should use the
mask everyevent - kHighLevelEvent even if your app isn't AppleEvent
aware.  If you don't, someday you might convert to AppleEvent aware
and forget about those pesky GetNextEvents at the beginning of your
App.

GetNextEvent( 0, &event ) might be an even better idea if it circumvents
the MF problem in 6.0.x; I haven't looked into it.  I believe that it's
not necessary at all under System 7.
-- 
-----------------	----------------------
Greg Anderson		User Programming Group	    ()    "Ponnuki
greggor@apple.com	Apple Computer, Inc.	  ()  ()   is ideal
-----------------	----------------------	    ()     shape."

smoke@well.sf.ca.us (Nicholas Jackiw) (06/12/91)

In article <53745@apple.Apple.COM> greggor@Apple.COM (Greg L. Anderson) writes:
>>If you're running under Multifinder on 6.x systems (or even if you're not),
>>the 10 calls to GetNextEvent() make sure that your window and process
>>are brought frontmost--an intermittent problem.
>
>Be careful about doing this on System 7; if your App just blindly calls
>GetNextEvent(everyevent) a few times when it starts up, you'll lose all
>of your open document high-level events if your app is AppleEvent aware.

The sample code provided was calling GNE() with an eventmask permitting
only updateEvents -- which avoids missed kHighLevelEvents (and other
significant boot-time events: disk inserts, special boot keycodes, etc.),
AND forces the toolbox to update any window the contents of which are
defined by a windowPic (the query expressed by the original poster).

>GetNextEvent( 0, &event ) might be an even better idea if it circumvents
>the MF problem in 6.0.x; I haven't looked into it.  I believe that it's
>not necessary at all under System 7.

That's correct--the problem is solved in System 7.  



-- 
                              --- * ---
Nick Jackiw                  Smoke@well.sf.ca.us   | Jackiw@cs.swarthmore.edu
Key Curriculum Press, Inc.   Applelink:KEY.EDUSOFT | (415) 548-2304
                              --- * ---