Notifications
Clear all

[Closed] activate deactivate using checkbox

i have this simple GUI with a checkbox “Enable All”…

when i click the checkbox i want to have all the spinners deactivated (greyed out)…when i enable it again i want all spinners active…how can i do it???

rollout test “Enable/Disable Test”
(
checkbox check “Enable All” tristate: 1
spinner spn1 “spinner 1” range: [1,10,5]
spinner spn2 “spinner 2” range: [1,10,5]
spinner spn3 “spinner 3” range: [1,10,5]
)

createdialog test

29 Replies
rollout test "Enable/Disable Test"
 (
 	checkbox check "Enable All" tristate: 0
 	
 	spinner spn1 "spinner 1" range: [1,10,5] enabled:false
 	spinner spn2 "spinner 2" range: [1,10,5] enabled:false
 	spinner spn3 "spinner 3" range: [1,10,5] enabled:false
 	
 	local all_spinners = #(spn1, spn2, spn3)
 
 	on check changed state do ( 
 		if state == true then (
 			for _spn in all_spinners do _spn.enabled = true
 		)
 		else (
 			for _spn in all_spinners do _spn.enabled = false
 		)
 	)
 )
 
 createdialog test

Just to add to the previous reply, you may want to simply the on check changed handler a little bit:

rollout test "Enable/Disable Test"
(
	checkBox check "Enable All" tristate: 0

	spinner spn1 "spinner 1" range: [1,10,5] enabled:false
	spinner spn2 "spinner 2" range: [1,10,5] enabled:false
	spinner spn3 "spinner 3" range: [1,10,5] enabled:false

	local all_spinners = #(spn1, spn2, spn3)

	on check changed state do all_spinners.enabled = state
) 
createDialog test
1 Reply
(@patriculus)
Joined: 11 months ago

Posts: 0

Thank you Swordslayer and blake_spector…the script from Swordslayer is easier…can i disable rollouts using this same way??

Oh, yeah that makes sense. Didnt know that you can access the properties directly from the array in that manner. Good to know for future reference, thx!

Depends on what you mean by disabling the rollouts; what do you want to achieve?

Switching states of all controls in an array is easy:

try destroyDialog myRol1 catch()
try destroyDialog myRol2 catch()

rollout myRol1 "1" width:100
(
	spinner spn1 "spinner 1" range: [1,10,5] enabled:false
	spinner spn2 "spinner 2" range: [1,10,5] enabled:false
	spinner spn3 "spinner 3" range: [1,10,5] enabled:false
	
	local all_spinners = #(spn1, spn2, spn3)
	
	on check changed state do all_spinners.enabled = state --or  ... .visible = state
)
	
rollout myRol2 "2" width:100
(
	checkBox check "Enable All" tristate: 0
	
	on check changed state do myRol1.controls.enabled = state
)

createDialog myRol1
createDialog myRol2
setDialogPos myRol2 [(getDialogPos myRol2).x,(getDialogPos myRol1).y + myRol1.height + 20]

My pleasure, mapped property assignments are nice, indeed

this is the code

rollout rolldisable “rollout disable” height: 150
(
subrollout test1 “test1”
subrollout test2 “test2”
)

rollout disableroll “disable Rollout”
(
button btn “Disable Below Rollout”
on btn pressed do
btn.text = “Enable CheckBox”
)

rollout check “Checkboxes”
(
checkbox chk “Disable Me”
)

createdialog rolldisable

addSubRollout rolldisable.test1 disableroll

addSubRollout rolldisable.test2 check

rolldisable.test1.height += 50

rolldisable.test2.height += 150

rolldisable.test2.pos +=[0,60]

here what i want to acheive is two things

  1. when i press “Disable below Rollout” i want Disable Me checkbox greyed out

  2. when the “Disable below Rollout” is pressed it will change the text to “Enable CheckBox”…so obviously when i press it again i want the check box to become active again

Like this¨?

try destroyDialog rolldisable catch()

rollout rolldisable "rollout disable" height: 150
(
	subrollout test1 "test1"
	subrollout test2 "test2"
)

rollout disableroll "disable Rollout"
(
	local captions = #("Disable Below Rollout","Enable CheckBox")

	button btn "Disable Below Rollout"
	
	on btn pressed do
		case findItem captions btn.text of
		(
			1:(check.chk.enabled = false; btn.text = captions[2])
			2:(check.chk.enabled = true; btn.text = captions[1])
		)
)

rollout check "Checkboxes"
(
	checkbox chk "Disable Me"
)

createDialog rolldisable
addSubRollout rolldisable.test1 disableroll
addSubRollout rolldisable.test2 check

rolldisable.test1.height += 50
rolldisable.test2.height += 150
rolldisable.test2.pos += [0,60]
1 Reply
(@patriculus)
Joined: 11 months ago

Posts: 0

woohooo…exactly like that…Thank you…:):):)

i created a GUI but i cant seem to get this work…i have two rollouts here…the second rollout has two checkboxes…so basically when i press btn2 i want to disable those two checkboxes…

on btn2 pressed do
(
if (Vray) == undefined then
(
messagebox “whoops…sorry”
)
else
(
renderers.current = Vray()
all_checkboxes.enabled = false
)

)

it says “–Unknown property: “enabled” in undefined”

Post your complete code, a small snippet can’t really be diagnosed.

-Eric

rollout rndr “vray switcher”
(
button btn1 “About”
button btn2 “Switch To Vray”

on btn1 pressed do
(
    messagebox "Under Development"
)

on btn2 pressed do
(
    if (Vray) == undefined then
(
    messagebox "whoops..sorry"
)    
else
(
    renderers.current = Vray()
)

)
)

rollout disable “Disable Rollout”
(
checkbox chk1 “Disable one”
checkbox chk2 “Disable two”
)

theFloater = newrolloutFloater “Checkbox Disable” 200 165

addRollout rndr theFloater

addRollout disable theFloater

createdialog rndr

this is the complete code…

Page 1 / 3