Important: The information in this document is obsolete and should not be used for new development.
Factoring Your Application for Recording
The recommended way to make your application recordable, or capable of sending Apple events to itself whenever a user performs a significant action, is to factor the code that controls your application's user interface from the code that responds to the user's manipulation of the interface. A fully factored application translates user actions into Apple events that the application sends to itself to initiate tasks.The examples that follow demonstrate how to factor code that responds to relatively simple user actions such as creating a new document or moving a window. They are intended only to illustrate the general approach you should take; many of the decisions you will need to make while factoring will be unique to your application. "What to Record," which begins on page 9-14, provides guidelines for deciding which user actions to record and how to record them. For examples of factored applications, see the AppleScript Software Developers' Kit.
If you are factoring an existing application, it's usually a good idea to begin with the required Apple events and any other Apple events that you plan to send in order to execute commands in the File menu. You can then proceed to other menu commands and mouse actions. If you are designing a new application and want to make it recordable, you should build factoring into every aspect of your application design.
Subtopics
- Factoring the Quit Command and the New Command
- Sending Apple Events Without Executing Them