Developer Documentation
PATH  Mac OS X Documentation > Making Your Applications Scriptable

Making Your Applications Scriptable

Previous | Chapter contents | Next | Book PDF

Default Suites

The Yellow Box frameworks includes two suites--exported declarations of scriptability--that application's get "for free": the Core suite and the Text suite. In these suites, the Application Kit exports scriptable APIs for many of the key classes, such as NSApplication, NSDocument, NSWindow, NSColor, and NSTextStorage.

Suites have nonlocalized and localized definitions, which are contained in external files loaded by a scriptable application. The nonlocalized file is called a "suite definition," and the localized one is called a "suite terminology." You can use any text editor to examine the class, command, and terminology definitions contained in these files. Suite definitions are located in the (nonlocalized) Resources directory of an application, framework, or bundle. For example, if you have a framework named MyStuff, you would look for a suite definition (named MyStuff.scriptSuite) at:

MyStuff.framework/Resources/

Suite terminologies--which map special AppleScript terminology to the class and command descriptions in the suite definition--are located in localized .lproj subdirectories of the Resources directory. For example, if the same framework has a suite terminology for the French dialect, you would find it ( MyStuff.scriptTerminology ) in:

MyStuff.framework/Resources/French.lproj/

For more on suites, see " Creating Suite Definitions and Suite Terminologies ."

Core Suite

The Core suite provides default implementations for most AppleScript commands. It also defines scriptability for document-based applications (that is, applications based on the Application Kit's document architecture). The suite also supports strings as a primitive type for properties.

Supported AppleScript commands : (all) Get, Count, Exists, Move, Copy, Create, Delete, Set; (NSDocument) Print, Save, Open, Close. Note that there is no default implementation for the Print command.

Table 1. Core Suite Attributes and Relationship

Class
Attributes
Relationships

all

class name, class code

NSApplication

name, active flag, version

documents, windows

NSDocument

filename (complete path), last component of file name, edited flag

NSTextStorage

foreground color, font name, font size

characters, text

NSWindow

tier number, title, various binary-state attributes

document

NSColor

color

Text Suite

The Text suite provides scriptability for the text object (NSText and related classes, particularly NSTextStorage). You can acquire this functionality for your application simply by adding the text object to your graphical user interface; you can add the text object programmatically or by dragging it from Interface Builder's DataViews palette.

The Text suite does not directly support any AppleScript commands--it inherits the support it offers from the Core suite--but it does specify the following attributes and relationships:

Table 2. Text Suite Attributes and Relationships

Class
Attributes
Relationships

NSTextStorage

font name, font size, foreground color

characters, words, paragraphs, attribute runs, text

NSAttachmentTextStorage

filename

Other Suites

Many of the standard Yellow Box applications, frameworks, and bundles will be made scriptable over time. The Sketch (formerly Draw) example project also includes its own suites; this project provides a good source of example code related to scripting.


Making Your Applications Scriptable

Previous | Chapter contents | Next | Book PDF