0

In my AppleScriptObjC program, I have lots of checkboxes. I have a script that loops through a list with each of the item identifiers for the button as strings. I want it to activate each of the buttons' setState_ methods based off of parameters. In short, I'm looking for something like this:

    set strIdentifier to "button identifier"
    [magic code here!]
    strIdentifier's setState_(1)

Any help would be appreciated!

russellsayshi
  • 2,449
  • 5
  • 17
  • 21

1 Answers1

0

I don't think there is any 'magic' to do this. My intention would be to iterate through the controls in the parent view of your checkboxes, like this:

repeat with aSubview in theParentView's subviews()
    if aSubview's title()'s isEqualToString_("Check") is not 0 then
        aSubview's setState_(false)
    end if
end repeat

Here, theParentView is an outlet to the view in which the checkboxes reside. There are basically two options to this:

  • For each identifier, you loop through the subviews
  • You loop through the subviews once and add them to a dictionary, with the identifiers as keys. Later, you can access the checkbox via an access to the dictionary.

In the second case, the code could look like this:

set aDict to NSMutableDictionary's alloc()'s init()

repeat with aSubview in theWindow's subviews()
    aDict's setObject_forKey_(aSubview, aSubview's title())
end repeat

aDict's objectForKey_("Check 1")'s setState_(false)
Entropia
  • 154
  • 9