Subscribe Bookmark RSS Feed

Select All Checkbox

aallman

Contributor

Joined:

Feb 28, 2017

I made a script that contains a list of check boxes followed by a "Select All" Check box.  I set the function of the "Select All" check box to select all of the other boxes when it is checked, but now I cannot figure out how to uncheck all the other boxes when the "Select All" check box is unchecked.

 

Any suggestions?

V List Box(

othicb = Check Box( {"MOErA*", "MOErC*", "MOErT*", "MOErG*"} ),

Spacer Box( 25 ),

H List Box(othia = Check Box( " ", <<SetFunction( othicb << Set All( 1, run script( 1 ) ) ) ), Text Box("Select All Thioated MOE", <<Set Width(90), <<Set Wrap(90)))

),

 

1 ACCEPTED SOLUTION

Accepted Solutions
Justin_Chilton

Joined:

Aug 27, 2015

Solution

Instead of always setting all values to 1, you will want to set the values to the value of the Select All Check Box. You can do this using the Get message. See example below for details.

New Window( "test",
	V List Box(
		othicb = Check Box( {"MOErA*", "MOErC*", "MOErT*", "MOErG*"} ),
		Spacer Box( 25 ),
		H List Box(
			othia = Check Box(
				" ",
				<<SetFunction( 
					function({this},
						othicb << Set All( this << Get, run script( 1 ) )
					)
				)
			),
			Text Box(
				"Select All Thioated MOE",
				<<Set Width( 90 ),
				<<Set Wrap( 90 )
			)
		)
	)
);
Justin
2 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

You have the answer in your own code.  Take a look at the code below, and also take a look into the Scripting Index for the Check Box()

     Help==>Scripting Index==>>CheckBox

Names Default To Here( 1 );
New Window( "test",
	V List Box(
		othicb = Check Box( {"MOErA*", "MOErC*", "MOErT*", "MOErG*"} ),
		Spacer Box( 25 ),
		H List Box(
			othia = Check Box(
				" ",
				<<SetFunction(
					If( othia << get( 1 ) == 1,
						othicb << Set All( 1, run script( 1 ) ),
						othicb << Set All( 0, run script( 1 ) )
					)
				)
			),
			Text Box( "Select All Thioated MOE", <<Set Width( 90 ), <<Set Wrap( 90 ) )
		)
	)
);
Jim
Justin_Chilton

Joined:

Aug 27, 2015

Solution

Instead of always setting all values to 1, you will want to set the values to the value of the Select All Check Box. You can do this using the Get message. See example below for details.

New Window( "test",
	V List Box(
		othicb = Check Box( {"MOErA*", "MOErC*", "MOErT*", "MOErG*"} ),
		Spacer Box( 25 ),
		H List Box(
			othia = Check Box(
				" ",
				<<SetFunction( 
					function({this},
						othicb << Set All( this << Get, run script( 1 ) )
					)
				)
			),
			Text Box(
				"Select All Thioated MOE",
				<<Set Width( 90 ),
				<<Set Wrap( 90 )
			)
		)
	)
);
Justin