Language Guide
CHAPTER 9
Script Objects
Inheritance and Delegation 281
When AppleScript encounters the Tell statement, it sends a Beep command to
script Joe. The Beep handler causes the default target application (for example,
the Script Editor) to display a dialog box that gives the user a choice about
hearing the alert sound. If the user clicks Yes, the handler uses a Continue
statement to pass the Beep command to the default target application. If the
user clicks No, the target application never receives the Beep command and no
alert sound is heard.
In applications that allow you to attach script objects to application objects, you
can use a handler for an application command in a script object to modify the
way the application responds to the command.
For example, if a drawing application allows you to associate script objects
with geometric shapes such as circles or squares, you could include a handler
like this in a script object associated with a shape in a document:
on move to {x, y}
continue move to {x, item 2 of my position}
end move
Whenever the shape the script object is associated with is named as the target
of a Move command, the on move handler handles the command by modifying
one of the parameters and using the continue statement to pass the command
on to the default parent—that is, the drawing application. The location
specified by {x, item 2 of my position} has the same horizontal
coordinate as the location specified by the original Move command, but
specifies the shape’s original vertical coordinate (item 2 of the circle’s original
position), thus constraining the shape’s motion to a horizontal direction.
The documentation for applications that allow you to associate script objects
with application objects in this manner should provide more information about
how to write handlers for application commands.
The Parent Property and the Current Application 9
The default parent property for any script that doesn’t explicitly declare one is
the default target application—usually, the application that is running the
script, such as the Script Editor. You can use the predefined variable current
application to refer to either the default target application or whatever
application is currently set as a script’s parent property.