Fun and games with Applescript "Standard Suite" in Cocoa app.
Fun and games with Applescript "Standard Suite" in Cocoa app.
- Subject: Fun and games with Applescript "Standard Suite" in Cocoa app.
- From: "Neal A. Crocker" <email@hidden>
- Date: Wed, 22 Aug 2001 23:10:29 -0700
I've been trying to learn how to implement scripting support in Cocoa
and I've come up with a number of questions that I can't find answers
to in the Cocoa, Carbon and Interapp. Communication documentation. I
was hoping I could find someone (or many someones) with answers to
these question here. For instance, how do I go about modifying or
orverriding the "Standard Suite" in my application? When I created a
scriptable version of the canonical "Nothing" Cocoa application in
Project Builder (by creating a Cocoa application and doing nothing
more than adding the application setting NSAppleScriptEnable with
value YES), it had a scripting dictionary which included the Standard
Suite (as I expected from reading the Cocoa documentation). The
Standard Suite doesn't appear to have a "run" command. I'd like to
put the strangely absent "run" command back into the Standard Suite
where, as far as I know, it belongs. Unfortunately, I can't figure
out what handles the "loading" of the Standard Suite when the Script
Editor asks for my app.'s dictionary (is it NSScriptSuiteRegistry?),
nor how to prevent this loading and cause the loading of my own
version. I'm also wondering if there is a way to override pieces of
the Standard Suite without simply replacing the whole thing with my
own version (assuming I can figure out how to do even that much). I
suppose I could put a "run" command in my application suite, but that
seems awkward. I'd also like to modify the Standard Suite so that I
could, for instance, add and eliminate properties from the
"application" object, or one of the other defined objects. I've
noticed that some other scriptable cocoa apps (e.g. Sketch) define
objects in their script suites that are already defined in their
Standard Suite, but define them with different properties and/or
element classes. Not only does this seem awkward, it bewilders me.
If an Applescript is compiled against such a dictionary, how are such
conflicts resolved?.
On a related note, how do I implement some behaviour for Applescript
commands such as "quit" or "run" (not just for the intial app.
startup, but for every time app. receives the "run" appleevent) for
the application object. The documentation seem clear on how to
implement behavior for my app. model classes, but not for the
application object.
Thanks,
Neal