Help! Problems to make app scriptable
Help! Problems to make app scriptable
- Subject: Help! Problems to make app scriptable
- From: Edison Thomaz <email@hidden>
- Date: Sun, 14 Sep 2003 01:57:27 -0700
Hi,
I am trying to make an app scriptable and it's been a pretty
frustrating experience - echoed by others who tried to do that as well.
I would appreciate if someone could point out what's wrong with what I
am doing.... I think i've gone through all the threads in the archives
and still can't find the problem here...
My app is a typical Cocoa app following the MVC pattern. The controller
class is of type NSObject and it's a delegate of NSApplication - made
the delegate connection within IB. The controller class has one
NSString that I want to access using AppleScript. I created the setter
and getter for the NSString following the required key-valued coding in
the controller, in addition to an accessor for the to-one relationship
in the controller that returns itself. In the Info.plist, everything is
good, Applescript is enabled and the Principal Class is set to
NSApplication.
In my scriptSuite file, I created two classes, one of type
NSApplication and one of type Controller. The NSApplication has a
To-One relationship to the Controller, since there is one controller
for one NSApplication. I implemented application: delegateHandlesKey in
the Controller class as well. The Controller class has one property, a
NSString. All the codes seem to match - I am using the Suite Modeler.
When I open the app with the Script Editor, I see:
Class user: TimeLife's User Object
Plural form:
users
Properties:
<Inheritance> item [r/o] -- All of the properties of the superclass.
current state: Unicode text [r/o] -- Return current user state
Class application: TimeLife's Top Level Scripting Object
Plural form:
applications
Elements:
document by name, by numeric index, before/after another element, as a
range of elements, satisfying a test
window by name, by numeric index, before/after another element, as a
range of elements, satisfying a test, by ID
Properties:
<Inheritance> application [r/o] -- All of the properties of the
superclass.
user: user [r/o] -- TimeLife User Object
The first thing that is I don't understand is why "user" is showing up
under "Properties" in the application class. "user" is the name of my
Controller class and since it's connected by means of a to-one
relationship, it should be under "Elements".
Here is my scriptSuite:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"
http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AppleEventCode</key>
<string>TLIFE</string>
<key>Classes</key>
<dict>
<key>NSApplication</key>
<dict>
<key>AppleEventCode</key>
<string>capp</string>
<key>Superclass</key>
<string>NSCoreSuite.NSApplication</string>
<key>ToOneRelationships</key>
<dict>
<key>tlcontroller</key>
<dict>
<key>AppleEventCode</key>
<string>Tlct</string>
<key>ReadOnly</key>
<string>YES</string>
<key>Type</key>
<string>TLController</string>
</dict>
</dict>
</dict>
<key>TLController</key>
<dict>
<key>AppleEventCode</key>
<string>Tlct</string>
<key>Attributes</key>
<dict>
<key>currentUserState</key>
<dict>
<key>AppleEventCode</key>
<string>cStr</string>
<key>ReadOnly</key>
<string>YES</string>
<key>Type</key>
<string>NSString</string>
</dict>
</dict>
<key>Superclass</key>
<string>NSCoreSuite.AbstractObject</string>
</dict>
</dict>
<key>Name</key>
<string>TimeLifeSuite</string>
</dict>
</plist>
and my scriptTerminology:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"
http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Classes</key>
<dict>
<key>NSApplication</key>
<dict>
<key>Description</key>
<string>TimeLife's Top Level Scripting Object</string>
<key>Name</key>
<string>application</string>
<key>PluralName</key>
<string>applications</string>
<key>ToOneRelationships</key>
<dict>
<key>tlcontroller</key>
<dict>
<key>Description</key>
<string>TimeLife User Object</string>
<key>Name</key>
<string>user</string>
</dict>
</dict>
</dict>
<key>TLController</key>
<dict>
<key>Attributes</key>
<dict>
<key>currentUserState</key>
<dict>
<key>Description</key>
<string>Return current user state</string>
<key>Name</key>
<string>current state</string>
</dict>
</dict>
<key>Description</key>
<string>TimeLife's User Object</string>
<key>Name</key>
<string>user</string>
<key>PluralName</key>
<string>users</string>
</dict>
</dict>
<key>Description</key>
<string>TimeLife AppleScript Classes</string>
<key>Name</key>
<string>TimeLife Suite</string>
</dict>
</plist>
What I want to do in AppleScript is something like:
tell application "TimeLife"
activate
get current state of user
end tell
but instead, I am getting an error: "Can't get current state of user"
Any help would be appreciated!! This is driving me nuts!
Thanks,
Edison Thomaz
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.