Disable objects

Hey guys what would be the most effective way to disable a heap of slider bars and buttons when a combo box is seleted on one item.

What i plan is to have a combo box with two options but 1 of the options doesnt require extra configuration so it would be best to disable the other items.

At the moment i use preferences to store this data so is there a way to do it in IB or would it need lots of lines disabling each item when it loads or detects a change in the box?

Hi Semaja,

you could place all optional controls in a box. Then you can easily disable (enable) them with

	set enabled of controls of box "box" of window "main" to false -- (true)

Dominik

semaja2,

What I usually do in this situation is write a subroutine that handles only this one feature. This will allow you to not only have a finite list of items you are handling, it also gives you a bit more flexibility with what happens to the items when you do the transition… such as enabling, setting state, and setting content.

For example…

on clicked theObject
	if name of theObject is "showMoreOptions" then
		set shouldShowOptions to (state of theObject) as boolean
		ToggleExtraOptions(shouldShowOptions)
	end if
end clicked

to ToggleExtraOptions(optionsShown)
	tell window "Main"
		set enabled of button "button1" to optionsShown
		set enabled of button "button2" to optionsShown
		set enabled of button "button3" to (not optionsShown)

		if optionsShown then
			set content of text field "textField1" to defaultOption
		else
			set content of text field "textField1" to ""
			set state of button "button3" to false
		end if
	end tell
end ToggleExtraOptions

*Note that the above code is off the top of my head, and shows the concept… not necessarily complete/compilable code.:stuck_out_tongue:

Good luck,
j

Well since the controls were already in a box i used dominiks method, thanks to both of yous for your help