Notifications
Clear all

[Closed] activate deactivate using checkbox

There are many ways to do that, one of them is:

rollout rndr "vray switcher"
 (
 	button btn1 "About"
 	button btn2 "Switch To Vray"
 	
 	local checkboxes
 	
 	on btn1 pressed do
 	(
 		messagebox "Under Development"
 	)
 	
 	on btn2 pressed do
 	(
 		if (Vray) == undefined then
 		(
 			messagebox "whoops..sorry"
 		)
 		else
 		(
 			renderers.current = Vray()
 			checkboxes.enabled = false
 		)
 	)
 	
 	on rndr open do
 		checkboxes = for ctrl in disable.controls where isKindOf ctrl CheckBoxControl collect ctrl
 )
 
 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

Or you can declare an array containing the checkboxes in the other rollout and acces that:


global disable -- or just switch the order in which you declare rollouts

 ...

 		else
  		(
  			renderers.current = Vray()
  			disable.checkboxes.enabled = false
  		)

 ...

 rollout disable "Disable Rollout"
  (
 	checkbox chk1 "Disable one"
  	checkbox chk2 "Disable two"
 
 	local checkboxes = #(chk1, chk2)
 )
 

you’ve been so helpful to me…i just cant stop thanking you…i would like to get one more help…

http://forums.cgsociety.org/showthread.php?f=98&t=950557

see the last post…can u insert it in this script

rollout rndr “vray switcher”
(
button btn1 “About” width: 110
button btn2 “Switch To Vray” width: 110
button btn3 “Switch To Quicksilver” width: 110

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

1 Reply
(@swordslayer)
Joined: 11 months ago

Posts: 0

Glad that I can be of some assistance. Anyway, inserting this piece of code is not all that hard and the explanation provided is more than sufficient, go on and try it that’s the best way to learn fast

Thank you…now i got it worked…:applause:

how can i change the text in rcMenu…i tried this but changes nothing

rcMenu menu
(
menuitem mymenu “Text Change”
on mymenu picked do
(
mymenu.text = “Changed”
)
)

I guess you’re declaring the rcmenu everytime the event you bind it with is fired. Otherwise it works with no problems if you first declare the rcmenu and then change its properties in the event handler. If you want to keep it inside the scope of the rollout, declare it on rollout open:

try destroyDialog test catch()
 rollout test ""
 (
 	local rc_menu
 
 	button btn
 
 	on test open do
 	(
 		rcMenu rc_menu
 		(
 			menuitem mymenu "Text Change"
 		
 			on mymenu picked do
 			(
 				mymenu.text = "Changed"
 			)
 		)	
 	)
 
 	on test rbuttonup pos do
 		popUpMenu rc_menu
 )
 createDialog test

Just as a sidenote, it’s better if you use the CODE tag for code instead of QUOTE, otherwise you lose tabs/spaces at the beginning of line and some pieces of code might be interpreted as text formatting tags.

try destroyDialog test catch()
 rollout test ""
 (
	 local rc_menu
 
	 button btn "button"
 
	 on test open do
	 (
		 rcMenu rc_menu
		 (
			 menuitem mymenu "Text Change"
		 
			 on mymenu picked do
			 (
				 mymenu.text = "Changed"
			 )
		 )	
	 )
 
	 on test rbuttonup pos do
		 popUpMenu rc_menu
 )
 createDialog test menu: rc_menu

i copied your script and added “menu: rc_menu” at the end…when i press CTRL+E it the rcmenu is already “Changed”…what i want was “Text Change’ and when i click it i want to change to “Changed”

Okay, so I did completely different thing than what you actually wanted (rightclick somewhere in the rollout and see how that one works). Next time it would be nice if you could attach a working snippet showing your problem, otherwise it’s just guesswork.

Doing it like this of course won’t work (with rcmenu declaration inside the rollout scope, created on rollout open) because you need it to exist before rollout gets opened. The menu that got assigned to your rollout is the global one that stayed in memory as a result of your previous tests. As far as I know the thing you want to achieve will not work, it will work in the rightclick menu as it gets created over and over again but I don’t know about a method for menustrip to change its captions once it’s registered as a menustrip…

It should be possible with dotnet or by faking it but the question is if it’s actually needed. Usually you don’t need to change the menuitems once the script is evaluated so having just on rc_menu open handler taking care of the captions on dialog creation should be enough…

if its not possible its ok…but please help me with this…

rollout test "renderers"
(
	button btn1 "Vray"
	button btn2 "QuickSilver"
	button btn3 "ntracer"

	on test open do
(
	btn1.enabled = false
	if (Vray) != undefined then
	(
	btn1.enabled = true
	)
)

on test open do
(
	btn2.enabled = false
	if (Quicksilver_Hardware_Renderer) != undefined then
	(
	btn2.enabled = true
	)
)

on test open do
(
	btn3.enabled = false
	if (ntracer_renderer_cuda) != undefined then
	(
		btn3.enabled = true
	)
)
)

createdialog test

from this script you understand how it shud look…but when i evaluate it all buttons are visible…i dont have quick silver coz am using max 2010…and if i shift true/false vice versa in ntrace that button becomes greyed out…if i do the same in vray nothing happens…button is always clickable

There should be only one on test open handler containing all the if/then tests, otherwise only the last one gets actually fired (by declaring it you’re creating a function open() that gets called on rollout open, here you redeclare it three times so only the last one gets evaluated on dialog creation).

thanks works perfect…how can i add two tooltips to one button…i mean when the button is disabled i want to show “button not set” and when the button is enabled i want to show “button set”…

Page 2 / 3