Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript-Cocoa Impedance Mismatch



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

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-implementors mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-implementors/email@hidden

This email sent to email@hidden
References: 
 >AppleScript-Cocoa Impedance Mismatch (From: Major Domo <email@hidden>)
 >Re: AppleScript-Cocoa Impedance Mismatch (From: Christiaan Hofman <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.