Is it possible for a button in a Cocoa application to issue calls to both a cocoa method (by use of a controller class) and an apple script handler as defined by the Applescript tab of the Info panel?
I would like to have a button that executes compiled code, but has an extra attached script that can be managed outside the application to attach custom behavior. I have tried to set it up myself, but the application will only use the last method that I established in Interface builder. For example, If I control drag an connection from my button to my controller last then that’s what my application use, but if I uncheck and check the onclick box under the applescript tab in the info panel last that that is what my application uses.
I was afraid you were going to say that. OK, so I’ve got that solution running, thanks, but is it possible to run a specific AppleScript function with in a script or is the run script all I can hope for?
Use -executeAppleEvent:error:. You’ll need to pack the Apple event yourself, which you can do using NSAppleEventDescriptors (though it’s a bit tedious) or you can use objc-appscript; there’s a sample project in the subversion repository that demonstrates how to call a user-defined subroutine.