Re: Handle AppleScript command using a delegate;
Re: Handle AppleScript command using a delegate;
- Subject: Re: Handle AppleScript command using a delegate;
- From: Matt Budd (Madentec) <email@hidden>
- Date: Mon, 28 Feb 2005 14:08:34 -0700
Thanks Tommy,
I totally missed that. However, I can't seem to get it to work when I add a parameter in my test AppleScript. If I do a "mytestcommand YES" or something like that, I get the same error.
I tried then changing my .sdef to have my command declared without a parameter (i.e. commented out the "<parameter" section), and then when I executed the original AppleScript, I no longer got the error but I did not get my handler code executing either....weird.
I guess I can try and figure it out in stages...if I can get it to work without a parameter (i.e. get it to execute my hander method in the delegate), then I will try and figure out the parameter stuff. So assume the parameter stuff is commented out, is there any reason this would not work?
- Matt
On Feb 28, 2005, at 1:58 PM, Tommy Nordgren wrote:
Your command is declared to take a parameter, but your test script don't include one.
Feb 28, 2005 kl. 8:07 PM skrev Matt Budd (Madentec):
Hello all,
I've been trying to make a sample cocoa application AppleScriptable to see how much work it would be for one of our main applications. The article at http://developer.apple.com/cocoa/applescriptforapps.html is very helpful to see how you can get properties implemented using a delegate for your NSApplication. The problem is that the article doesn't explain how to do commands the same way.
For example, I can right now perform the following AppleScript:
tell application "Scriptease"
set mytestproperty to "test"
end tell
and it works correctly. However, when I try this AppleScript in the script editor
tell application "Scriptease"
mytestcommand
end tell
it complains saying NSCannotCreateScriptCommandError
Here is a portion of my .sdef for the project:
<suite name="Scriptease" code="mlst"
description="Commands and classes for Scriptease">
<!-- Exposed Classes -->
<classes>
<class name="application" code="capp" description="The application class"
inherits="NSCoreSuite.NSApplication">
<cocoa class="NSApplication"/>
<properties>
<property name="mytestproperty" code="tprp" type="string"
description="My Test Property">
<cocoa method="ASTestProperty"/>
</property>
</properties>
<responds-to-commands>
<responds-to name="mytestcommand">
<cocoa method="ASTestCommand"/>
</responds-to>
</responds-to-commands>
</class>
</classes>
<!-- Exposed Commands -->
<commands>
<command name="mytestcommand" code="mlsttcmd" description="My Test Command">
<result type="boolean" description="My Test Retval"/>
<parameter name="mytestparam" code="tprm"
description="My Test Param" type="boolean"/>
</command>
</commands>
</suite>
And I've implemented this method in the delegate for my NSApplication (the same class that I did the methods for the properties (as in that article)):
- (void)ASTestCommand: (NSScriptCommand *)poCommand
{
NSLog(@"here"); //I never get here?!?
}
Has anyone got this to work and can see what I'm doing wrong? Most of the stuff that I've seen on implementing AppleScript commands involve subclassing NSScriptCommand, but that seems to be a bit overkill if you end up having a ton of AS-commands, wouldn't it? Any info would be appreciated...
- Matt _______________________________________________
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
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
_______________________________________________
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