Important: The information in this document is obsolete and should not be used for new development.
Chapter 14 -
This chapter includes recipes and sample code that demonstrate how to
Working With Scripting
For a detailed overview of MacApp's scripting support, see Chapter 6, "Scripting."
- support Apple events in your application (a general outline)
- define a recordable command class
- set object properties with Apple events
- support a custom Apple event
- write a simple script that can be attached to every window in your application
- override the
GetContainedObject
method to look for contained objects matching a type you are interested in- initialize MacApp's scripting support to use a custom subclass of
TOSADispatcher
(MacApp's global Apple event dispatcher object)
For related information, see "Recipe--Implementing a Recordable Drawing Command," beginning on page 375.
For more information on scripting, see Inside Macintosh: Interapplication Communication.
Chapter Contents
- Overview
- Creating an Object Specifier
- Recipes--Scripting
- Supporting Apple Events in Your Application--A General Outline
- Recipe--Defining a Recordable Command Class
- Override MakeAppleEvent in the TZoomInCommand Class
- Recipe--Setting Object Properties With Apple Events
- Identify the Property or Properties the Class Will Support
- Define an 'aete' Resource
- Mix in the MScriptableObject Class
- Initialize MScriptableObject With an Object Model Class ID
- Override GetObjectProperty and SetObjectProperty
- If Necessary, Override GetSetPropertyInfo
- Recipe--Supporting a Custom Apple Event
- Identify the Custom Apple Event
- Define an 'aete' Resource That Includes the Custom Event
- Define an 'aedt' Resource for the Custom Event
- Add the Mixin Class MScriptableObject
- If Necessary, Override Certain Methods of MScriptableObject
- Override DoScriptCommand to Handle the Custom Event
- Recipe--Attaching a Script to Objects in Your Application
- How MacApp Attaches the Script
- What Happens When the Script Is Executed
- Where You Go From Here
- Recipe--Overriding the GetContainedObject Method
- Define a Class That Mixes In the MScriptableObject Class
- Provide an Override Version of the GetContainedObject Method
- Recipe--Installing a Custom Subclass of TOSADispatcher
- Define a Custom Subclass of TOSADispatcher
- Register Your Custom Subclass
- Call the InitUScripting Method of Your Custom Subclass