Re: How to support 'every' object in script interface
Re: How to support 'every' object in script interface
- Subject: Re: How to support 'every' object in script interface
- From: Steve Palmer <email@hidden>
- Date: Sun, 26 Jun 2005 14:53:44 -0700
Thanks, Bill!
However a key first step before I can deal with the distinction is to
know where to handle the 'every' command. As I stated earlier,
there's no documentation that I could find that explains which method
has to be added where to handle it. From the stack trace below, Cocoa
is clearly expecting to find a specific method and is not finding it.
Are you able to advise me in that direction?
- Steve
On Jun 26, 2005, at 10:55am, Bill Cheeseman wrote:
on 2005-06-26 1:17 PM, Steve Palmer at email@hidden
wrote:
and the console log shows:
Direct Parameter: <NSPropertySpecifier: bar>
Receivers: <NSPropertySpecifier: bar>
Arguments: {}
I'll quote what I recently wrote to someone else about direct
parameter
handlers for lists and 'every'. Perhaps it will be helpful. --
-->
In Tiger with an sdef, my code comments remind me that:
1. When the direct parameter is an AppleScript list ('get {a, b,
c}'), it is
interpreted as an array containing multiple instances of
NSScriptObjectSpecifier, each of them specifying an object.
2. When the direct parameter is 'every', it is interpreted as a single
NSScriptObjectSpecifier, specifying an array of objects.
So, just make sure your command handler branches correctly to
handle the
difference between these two situations. Here's how I do it, with some
simplification:
a. Get directParameter and test it to see if it
isKindOfClass:[NSPropertySpecifier class] and, if so, if it
evaluates to
isKindOfClass:[NSArray class]. If it does, you know you're dealing
with the
'every' case -- case 2, above. Iterate the array and do what you
will with
its elements.
b. Else, you know the direct parameter was of the form '{a, b, c}',
as in
case 1, above. So, iterate the array of NSScriptObjectSpecifiers,
calling
objectsByEvaluatingSpecifier on each of them and then doing with it
what you
will.
<--
The above is for an sdef-only app running on Tiger (with the
OSAScriptingDefinition key defined in Info.plist. If you're running
under
Panther and older, the situation is a little different. In Panther and
older, AppleScript will send the 'every' case to your class, while
sending
the list case to your application delegate. I'm not saying this
quite right,
I think, but the basic idea is that you have to have a handler in both
classes to catch both list and 'every' in Panther and older.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40opencommunity.co.uk
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden