• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [q] scriptSuite conflict problems (code included)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [q] scriptSuite conflict problems (code included)


  • Subject: Re: [q] scriptSuite conflict problems (code included)
  • From: Brian Webster <email@hidden>
  • Date: Thu, 19 Jul 2001 10:34:16 -0500

On Thursday, July 19, 2001, at 12:16 AM, cocoa-dev-
email@hidden wrote:

I am trying to implement a minimal scripting suite into a Cocoa App. The
goal is to be able to do the following calls in an AppleScript:

tell application "JPSB"
set programState to 5
set localVar to programState
end tell

Where programState is an instance variable (with accessors) within my
Controller class. (Apparently, it shouldn't make a difference if I
attach it to a Model class or a controller class)

I think your problem here is that the programState is a property of your controller object, but you haven't exposed the controller object itself to Applescript. There are two ways of going about this. You can either a) expose the controller object as an element of NSApplication or b) expose any sort of global properties, such as programState in your example, directly as properties/elements of the NSApplication. I tend to prefer the latter, since it's somewhat cleaner from the scripter's point of view, but in either case, you'll need to add an entry for NSApplication in your script suite. Then, you'll need to either write a category(ies) on NSApplication to implement the functionality, or implement the scripting delegate method (application:delegateHandlesKey: or something along those lines - it's in the docs under protocols).

This suite exposes the property: (typed in Mail, errors probable)

{
Classes = {
NSApplication = {
Superclass = NSCoreSuite.NSApplication;
Attributes = {
programState = {
Type = NSNumber;
AppleEventCode = prst;
};
};
};
};
}

And BTW, you should be able to store your state as a plain int, and the scripting framework will handle the translation automatically.

--
Brian Webster
email@hidden
http://www.owlnet.rice.edu/~bwebster


  • Prev by Date: Re: [Help] NSTableDataSource and EXC_BAD_ACCESS
  • Next by Date: [Help] How to get instance of instantiated Controller in nib from Controller in another nib? (Java)
  • Previous by thread: [q] scriptSuite conflict problems (code included)
  • Next by thread: Switching off antialiasing...
  • Index(es):
    • Date
    • Thread