Checkboxes Maxscript

How can i make the button on top toggle all checkboxes to either all be true or alll be false disgarding what their current checkstate is.

Like a toggle button.

rollout test "test"
(
	button btnCheck "Check"
	checkbox ckbx1 "Stuff" checked:false
	checkbox ckbx2 "Option" checked:true
	checkbox ckbx3 "Anything" checked:true
	checkbox ckbx4 "Junk" checked:false
 
	on btnCheck pressed do
	(
 
	)
)
createDialog test 150 140

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
3dwannab's picture

This is how I've been doing it lately

First name your buttons internal name something that makes sense. If it's for affecting geo then put geo in there and mat for material so you can matchpattern of the control and turn it off depending on your button name.

Something like this:

fn collectControl_fn = /* collects only controls that can be enabled or disabled */
(
	mappablecontrols_ar = for ctrl in yourrolloutnamehere.controls where classof ctrl != GroupStartControl AND classof ctrl != GroupEndControl collect ctrl
	)
 
collectControl_fn ()
 
for ctrl in mappablecontrols_ar where matchPattern ctrl.name pattern:"*geo*" do ctrl.enabled = false
miauu's picture

Or use this to avoid problems

Or use this to avoid problems with checkbox names:

rollout test "test"
(
	button btnCheck "Check"
	checkbox ckbx1 "Stuff" checked:false
	checkbox ckbx_2 "Option" checked:true
	checkbox ckbx_3 "Anything" checked:true
	checkbox ckbx4 "Junk" checked:false
 
	on btnCheck pressed do
	(
		for aControl in test.controls do
		(
			case classof aControl of
			(
				CheckBoxControl: aControl.state = not aControl.state
			)
		)
	)
)
createDialog test 150 140
stenionet's picture

How can we make the

How can we make a Checkbutton turn off when we click in other tool?

Sorry. I post this in the wrong Topic.

Budi G's picture

You can create a function to

You can create a function to shorten the writing on this case, such:

rollout test "test"
(
  local state = true --choose false or true as start
  -------------------------------- button
	button btnCheck "Check"
	checkbox ckbx1 "Stuff" checked:false
	checkbox ckbx2 "Option" checked:true
	checkbox ckbx3 "Anything" checked:true
	checkbox ckbx4 "Junk" checked:false
 
  -------------------------------- function
     fn checked_all boolean =
     (
       ckbx1.checked = boolean
       ckbx2.checked = boolean
       ckbx3.checked = boolean
       ckbx4.checked = boolean
     )
 
  -------------------------------- execute
	on btnCheck pressed do
	(
          state = not state -- make vice versa
          checked_all state
	)
)
createDialog test 150 140
Swordslayer's picture

Or you can just collect the

Or you can just collect the checkboxes on dialog creation and check them en masse without having to rewrite the function every time you add or remove a checkbox:

rollout test "test"
(
  local state = true --choose false or true as start
  local checkboxes
 
  -------------------------------- button
	button btnCheck "Check"
	checkbox ckbx1 "Stuff" checked:false
	checkbox ckbx2 "Option" checked:true
	checkbox ckbx3 "Anything" checked:true
	checkbox ckbx4 "Junk" checked:false
 
  -------------------------------- execute
	on btnCheck pressed do
	(
          state = not state -- make vice versa
          checkboxes.checked = state
	)
 
	on test open do
		checkboxes = for c in test.controls where matchPattern c.name pattern:"ckbx*" collect c
)
createDialog test 150 140
mjbg's picture

Or you can only use

Or you can only use "ckbx.state = true"
lol.. my maxscript knolowedge is pretty basic.. so i dont usually use functions and complex commands

rollout test "test"
(
	button btnCheck "Check"
	checkbox ckbx1 "Stuff" checked:false
	checkbox ckbx2 "Option" checked:true
	checkbox ckbx3 "Anything" checked:true
	checkbox ckbx4 "Junk" checked:false
 
	on btnCheck pressed do
	(
 	ckbx1.state = true
 	ckbx2.state = true
	ckbx3.state = true
	ckbx4.state = true
 	)
)
createDialog test 150 140

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.