On Nov 1, 2007, at 1:09 PM, Christiaan Hofman wrote:
Did you have a look at the script support of the Sketch sample
project? IIRC it has a graphics element and several subtypes. I
think that works with subclasses, but that isn't necessary. You can
have several elements with the same class, one for each type of
medium.
Indeed, this is what we have now.
There is nothing to implicitly define the filtering as in
interpreting "book" as "media whose type is book", so you need to do
the filtering in the code, probably in the (scripting) accessors for
the different types of elements.
So, by way of experiment, since we were already subclassing
NSCreateCommand, I put in some logic that will do this translation and
it works great, but I also end up having to do all the work of
actually implementing the action. I was just hoping for something
lower-level, since subclassing and hand-implementing every verb seems
fraught with peril.
If you want to define different applescript types for the different
types, to do things like "make new book", I don't think that's
possible: different AS classes must be different Cocoa classes (I
think). So if you'd want something like that you'd have to make the
different types also different Cocoa classes.
This was how things used to be, but it just became unmanageable. If
only it weren't still such a useful construct in AppleScript...
Also, when you have a fixed number of types, I would use an
enumeration for the type rather than a string. It's clearer,
prevents abuse and mistyping, and mentions the possible values
automatically in the scripting dict.
Point well taken. We had done this, then undone it because it was not
working as expected with the subclasses, but now that those are done,
we might as well put this back.
Cheers,
Mike Lee, Major-domo
Delicious Monster Software, LLC