Toggle Checkbox (setState doesnt work)

Hi

I’m new to ASOJ. In fact, I’m new to AS in general :slight_smile:
Anyway, I’m playing around first, trying out how to do some basic stuff.

However I’m not able to check/uncheck a Checkbar.

It’s supposedly of the NSButton Class, and it should change the state with the setNextState command.

I tried it like this:


toggler's setNextState_(true)

Where “toggler” is the checkbox’s IBOutlet

The setTitle() however works and it’s for the same Class.
toggler’s setTitle_(“status”)

How can I check/uncheck a Checkbox?

You want setState_(1) or setState_(2). if you want to use the next state, it’s simply setNextState() – no parameter, and therefore no underscore.

Thanks, it works partly.

setNextState() works prefectlly.
setState_() does not.

None of these lines work:


toggler's setstate_(0)
toggler's setstate_(1)
toggler's setstate_(2)
toggler's setstate(0)
toggler's setstate(1)
toggler's setstate(2)
toggler's setstate_(void)
toggler's setstate_(true)
toggler's setstate_(false)
toggler's setstate(void)
toggler's setstate(true)
toggler's setstate(false)
toggler's setstate_(NSOffState)
toggler's setstate_(NSOnState)

Another observation which might be useful (I just noticed it, can’t match it to anything though) is that when I write “setnextstate” (lowercase) it translates it to “setNextState”, however when I write “setstate” it doesn’t get “recognized” and automatically correctly capitalized.

It’s as “setstate” doesn’t exist in in ASOC.

You need to match the case: setState. AS is case-insensitive, and uses whatever style you first enter and compile. To get around the problem, you can use pipes: |setState_|

Thanks I’ll try it out in a few days.
My iMac i7 (5 days old) has a malfunctioning harddrive (over 150million raw error read out or such) and is going in repair.
and on my macbook i dont have the developertools.

I do know that AS is casesensitive, thats why i have written the last paragraph.
Also, when I tried to write “setState_” the applescript automatically put everything in lowercase to “setstate_”, this is what caught my attention.

anyway, thanks for the input, but right now i don’t even have a working computer (the macbook is just for surfing/mail/etc). thanks apple :slight_smile:

thanks, it works now (the script and my iMac)
i think this can be closed :wink: