Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: responding to apple events



> Is it easy to mix cocoa and applescript in one program? Where would I add it anyway, main()?
 
Just to clarify a F.C.I. (Frequently Confused Issue), your AppleScript Studio application *is* Cocoa, using AppleScript as the language.  Cocoa supports three languages by default (more with third-party bridges): Objective-C, Java, and AppleScript.  Now to actually answer your question.  You would simply create an Objective-C Cocoa class (usually in a .h header file and a .m implementation file) and either instantiate it in Interface Builder or use call method to call its alloc and init methods (set instanceOfMyNewClass to call method "init" of object (call method "alloc" of class "MyNewClass")).  You can then use call method to execute the methods of your Obj-C object.
 
That's the easy part, getting AppleScript to talk to your Objective-C class.  The hard part is getting your Objective-C class to talk to your AppleScript.  There is no Obj-C equivalent of call method to call back to AppleScript handlers.  The kludge is to use either a hidden GUI control (usually a simple text field) or the defaults system to act as a "middleman" for communications.  The problem is that defaults is passive, though you might (as in I'm not sure and haven't tested this) be able to tie an on changed handler to your hidden GUI control to sort of make it reactive.
 
> oh.. and where do I find the ASK dictionary?
 
Easy, open Script Editor, select Open Dictionary... and find any AppleScript Studio application.  It will show you all the AppleScript Kit terms, since all AppleScript Studio apps use it.
 
Topher
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden

References: 
 >Re: responding to apple events (From: Justin van Berckel <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.