Re: Applescript command and sdef
Re: Applescript command and sdef
- Subject: Re: Applescript command and sdef
- From: Mike Abdullah <email@hidden>
- Date: Sun, 5 Mar 2006 01:10:21 +0000
- Resent-date: Sun, 5 Mar 2006 01:10:47 +0000
- Resent-from: Mike Abdullah <email@hidden>
- Resent-message-id: <email@hidden>
- Resent-to: email@hidden
I think I'm pretty sure what you're after since I recently began
doing such work myself on one of my apps. I've only done this for a
"simple" AppleScript command. I.e. the command has no parameters,
just a single instruction, however, I think it should be fairly easy
to extend it to cover parameters if required.
OK, so:
Step 1:
Create your basic .sdef file to be something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/
sdef.dtd">
<dictionary title="My App Terminology">
<suite name="My App Suite" code="MApS"
description="My App scripting support">
<command name="my command"
code="masdMyCm"
description="Carries Out My Command">
<cocoa class="MyScriptCommand"/>
</command>
</suite>
</dictionary>
As you can see, you just place in the appropriate values. The key
ones are:
Suite Code - This should be four letters and contain at least one
uppercase letter.
Command Code - This should be eight letter and contain at least one
uppercase letter. Generally, the first four letters are used to
prefix every command in your app.
Cocoa Class - This is the name of the class that the command will use
(and the really important one!)
Step 2:
Subclass NSScriptCommand and call it the same name as the Cocoa Class
you specified in the .sdef file. You need to override
performDefaultImplementation as this is the method that will be
called when the AppleScript command is carried out.
That should be about it, just also make sure you have scripting
support properly turned on etc.
Mike.
On 4 Mar 2006, at 18:37, Jacken wrote:
I wonder if anyone could point me to an example on how to make a
Applescript command. My program is 10.4 only, so I'm just using
a .sdef file to describe my applescript commands. I managed to get
setting and getting values, but I can't get a command going. I
tried to read Apple's documentation, but It always goes back to how
to do it the "old" way, not with .sdef files. All I need is for a
class method to be called when a applescript command is executed.
Anyone have an example or link to a web site with more info?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com
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