Technotes


GetNextEvent; Blinking Apple Menu



Technote TB 11August 1986



Revised by: March 1988
Written by: Rick Blair August 1986

Wherein arcane mysteries are unraveled so you can make the Alarm Clock (or a similar desk accessory) blink the Apple menu at the appointed second. Also, why GetNextEvent is a good thing.



The obvious

Don't disable interrupts within an application! There will almost certainly come a time (or Macintosh) where you won't be able to change the interrupt mask because the processor is running in user mode. The one-second interrupt is used to blink the apple.

The not-so-obvious

You must call GetNextEvent periodically. GetNextEvent uses a filter (GNE filter) which allows for a routine to be installed which overrides (or augments) the behavior of the system. The GNE filter is installed by pointing the low-memory global jGNEFilter (a long word at $29A) to the routine. After all other GNE processing is complete, the routine will be called with A1 pointing to the event record and D0 containing the boolean result. The filter may then modify the event record or change the function result by altering the word on the stack at 4(A7). This word will match D0 initially, of course.

A GNE filter is used to do the blinking when the interrupt handler has announced that the moment is at hand. GetOSEvent won't do. If you don't have a standard main event loop, it is generally a good idea to give GetNextEvent (and SystemTask, too) a call whenever you have any idle time. GetNextEvent "extra" services include, but aren't limited to, the following:

1. Calling the GNE filter.

2. Removing lingering disk-switched windows (uncommon unless memory is tight).

3. Making Window Manager activate, deactivate and update events happen.

4. Getting various events from a journaling driver when one is playing.

5. Giving SystemEvent a chance at each event.

6. Running command-shift function key routines (e.g. command-shift-4 to print the screen to an ImageWriter).

The more subtle

When the (default) GNE filter sees that the interrupt handler has set the "time to blink" flag, it looks at the first menu in MenuList. The title of that menu must consist solely of the "apple" character or no blinking will occur. It really just looks at the first word of the string to see if it is $0114. This is a Pascal string which has only the $14 "apple" character in it. So you musn't have any spaces or any other characters in the title of your first menu or you'll get no blinkin' results.


Further Reference:




Technotes
Previous Technote | Contents | Next Technote