The number 4 receiver error means that one of your objects is either not correctly named or you are using the wrong name in your script. I used a modified version of your code, which toggles the combo box on and off via the switch, with no problems.
on clicked theObject
if name of theObject is "chkAutoTx" then
if state of theObject is 1 then
set enabled of combo box "cboTxMakeCommand" of window "frmMain" to true
else
set enabled of combo box "cboTxMakeCommand" of window "frmMain" to false
end if
end if
end clicked
Unless you’ve got a nib corruption, I’m guessing you’ve just typed a name in wrong somewhere.
jobu, thanks so much for your reply. Unfortunately I am still stuck
I have deleted the objects in question and re-created them (well, not the main window since it has a bunch of other controls on it) and no luck. I have checked and re-checked the names of all the objects and no luck.
I did create a whole new project and tried it with just the check box and the combo box and that DID work. But I don’t want to have to re-create my whole interface because of this…
Would it be possible to mail the entire project to you and have you try it? All it is is a nib with two windows and enough code to open and close a window. 128KB zip file. I fully understand if you don’t want to or do not have the time.
If you’ve made all those changes and it still doesn’t work, sounds like a nib problem. I’d be happy to take a look, though…so send it over.
to SendMeEmail()
set myEmailAddress to "jobu10000 (a) yahoo . com"
tell application "Whatever You Use To Send Email"
send email to myEmailAddress
end tell
end SendMeEmail
jobu was able to take a quick look at my script and find the error. I am posting his response here so that others can learn from my mistake (and his magnanimous gift of time and knowledge):
quoted from jobu:
Hey. You just missed one easy thing. When you place
items into a box object, you must name the box and
then reference the items as sub-objects of the box.
In your case, all of your “options” buttons are in a
box. When you want to command them to do something,
you must use the full reference to them. For example,
you used…
set enabled of combo box “cboTxMakeCommand” of
window “frmMain” to true <<
…when you should be using…
set enabled of combo box “cboTxMakeCommand” of box
“theBox” of window “frmMain” to true <<
Make sure to name the box in Interface Builder as you
would any other AS object, and then add ‘…of box
“theBox”’ to any references you make to it, where
“theBox” is the name you give it in IB.
A workaround I use to avoid having to deal with lots
of objects in boxes, is to insert a box UNDERNEATH all
of the items I want to be “in” it. Create your other
objects as usual. Drag a box from the palette and
size it to fit around your objects so it looks like
they are in it. Then click on the box to select it,
and choose “Send to Back” from the Layout menu to make
it the bottom-most object in the window. The other
objects will appear to be in the box, but you can
still reference them as sub-objects of only the
window.