Handle AppleScript command using a delegate;
Handle AppleScript command using a delegate;
- Subject: Handle AppleScript command using a delegate;
- From: Matt Budd (Madentec) <email@hidden>
- Date: Mon, 28 Feb 2005 12:07:09 -0700
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