Understanding Messages and Events

Macintosh applications perform tasks in response to events. Users originate events with the keyboard and mouse or touchpad, and applications respond to the events by performing tasks. Similarly, an application can make other applications perform tasks by sending messages about events.

The events that applications send to each other in messages are called Apple events. AppleScript makes applications perform tasks by sending them Apple events.

When an application receives a message about an Apple event, the application takes a particular action based on the specific event. This action can be anything from performing a menu command to taking some data, manipulating it, and returning the result to the source of the Apple event message.

For example, when you choose macapple.jpg⇒Shut Down or macapple.jpg⇒Restart, OS X sends an Apple event message to every open application saying a Quit event occurred. For this reason, applications quit automatically when you choose macapple.jpg⇒Shut Down or macapple.jpg⇒Restart.

When you drop document icons on an application icon, the Finder sends a message to OS X saying ...

Get OS X Mountain Lion Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.