Window Related Events
Volume Number: 9
Issue Number: 1
Column Tag: Getting Started
Related Info: Event Manager Window Manager
Window Related Events
Handling update, activate and suspend/resume events
By Dave Mark, MacTech Magazine Regular Contributing Author
Note: Source code files accompanying this article are located on MacTech CD-ROM
or source code disks.
In last month’s column, we covered the basics of event loop programming,
focusing on four specific events: the mouseDown, mouseUp, keyDown, and autoKey
events. If you haven’t already, be sure to read through the Event Manager chapters in
Inside Macintosh, Volumes I and VI. Pay specific attention to the sections that describe
the mouseDown, mouseUp, keyDown, and autoKey events in detail. Finally, go back to
last month’s program and flesh it out a little. When a mouseDown occurs, draw a string
in the event window that describes where and when the mouseDown occurred. For a
keyDown, draw the character and key codes embedded in the EventRecord.
In this month’s column, we’re going to expand our event handling repertoire,
focusing on activate, update, and suspend/resume events.
Activate Events
Every time your application creates a window, that window is added to a list
maintained by the Window Manager. The windows in this list are in the order that they
appear on the screen, from the frontmost to the rearmost. The frontmost window is
also known as the active window. In Figure 1, Window #1 starts off as the active
window. Notice the difference between the title bars of the active and non-active
window.
When the mouse is clicked in the rear window, Window #1 is made inactive, then
the rear window, Window #2, is made active. Since the front window is made inactive
before another window is brought to the front, there will never be more than one
active window at a time!
The Window Manager accomplishes this by sending your application a series of