Re: How do I make a singleton object AppleScriptable?
Re: How do I make a singleton object AppleScriptable?
- Subject: Re: How do I make a singleton object AppleScriptable?
- From: Matt Neuburg <email@hidden>
- Date: Wed, 23 May 2007 13:46:57 -0700
- Thread-topic: How do I make a singleton object AppleScriptable?
Hey, Dave -
You're welcome to send me your project, but before you do - have you
compared what you're doing to this?
<http://developer.apple.com/samplecode/SimpleScripting/index.html>
That's pretty clear about what it takes to add one property to an app.
m.
On or about 5/23/07 1:05 PM, thus spake "Dave Camp" <email@hidden>:
> Sorry for the delay on following up on this... busy moving our office
> a block down the street...
>
> On May 21, 2007, at 12:25 PM, Matt Neuburg wrote:
>> It seems to me, from what you've said, that the answer is simple.
>> You have
>> an application. It has a property. End of story. The fact that this
>> property
>> really belongs, behind the scenes, to an "in-memory singleton
>> EngineController object" is irrelevant. That is something YOU know,
>> not
>> something AppleScript knows.
>
> Fair enough.
>
>> So go ahead and add a property to your AppleScript "application"
>> object in
>> exactly the same way you would normally do this. Let's say it's called
>> "prop" (since you do not say in your email what it is really
>> called). Set up
>> the sdef accordingly. Let us suppose that in the sdef the cocoa key
>> for
>> "prop" is "prop". Then go ahead and implement your category on the app
>> delegate, with methods "prop" and "setProp:". All done! It remains
>> only to
>> write the code.
>
> My sdef looks like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/
> sdef.dtd">
> <dictionary title="Foo Terminology">
> <suite name="Foo Suite" code="Cbnt" description="Terms and Events
> for controlling Foo">
>
> <class name="application" code="capp" description="The Foo
> application">
> <property name="mode" code="Mode" access="rw" description="Current
> mode of the Foo application">
> <type type="boolean" list="no"/>
> <cocoa key="backupMode"/>
> </property>
> </class>
> </suite>
> </dictionary>
>
> When I build my app I can view it's dictionary in the script editor
> and it looks as expected.
>
> I've added an instance variable to my app delegate:
> int backupMode;
>
>
> My sample AppleScript looks like:
>
> tell application "Foo"
> get mode of application
> end tell
>
> The script compiles fine, but when I run the script I get an error
> dialog that says: AppleScript Error: Can't get mode of application.
>
> I thought the problem might be that the app delegate might not work
> like that, so made a sub-class of NSApplication, added the instance
> variable, and set the file owner in my MainMenu.nib to my app sub-
> class, but I still get the same error. For whatever reason, it's not
> able to find my instance variable via KVO.
>
> What am I missing?
>
> Thanks,
> Dave
>
> ---
> You are in a maze of testy little Java VMs, all subtly different.
>
--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide - Second Edition!
http://www.amazon.com/gp/product/0596102119
Take Control of Word 2004, Tiger, and more -
http://www.takecontrolbooks.com/tiger-customizing.html
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden