cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Martin
Level V

Enable Modal Radio Box Items based on predefined list

I am trying to Enable/Disable certain radio box buttons in a single radio box based on a list I have entering the Modal dialog with.

 

For instance, say my list is {2, 5} and my radio box has 5 buttons in it. When the Modal window opens, I only want buttons 2 and 5 (from the list, which is based on previous user input) to be enabled and buttons 1, 3, and 4 to be disabled.

 

I've tried to add a For loop and an If loop with a Contains formula into the setting up of the radio box, but they seems to only get called when a different button is clicked in the radio box, not when it is originally set up.

 

Any help would be greatly appreciated. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Enable Modal Radio Box Items based on predefined list

Would example like this help?

Names Default To Here(1);

//radiobox variables
enableList = {2,5};
rbItems = {"one", "two", "three", "four", "five"};
rb = Radio Box(rbItems);

//start as all disabled
For(i = 1, i <= N Items(rb << get items), i++,
	rb << enable item(i,0);
);

//enable based on enableList
For(i = 1, i <= N Items(enableList), i++,
	rb << enable item(enableList[i],1);
);
//change first selection to first in enableList (otherwise will be first in rbItems)
rb << Set(enableList[1], 1);

//create modal
ok_pressed = 0;
ex = New Window("Dialog() example",
	<<Modal,
	V List Box(
		rb,
		H List Box(
			Button Box("OK", ok_pressed = 1; rbSelection = rb << get),
			Button Box("Cancel", ok_pressed = 0)
		)
	)
);

If(ok_pressed == 1,
	show(rbSelection);
	show(rbItems[rbSelection]);
);
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Enable Modal Radio Box Items based on predefined list

Would example like this help?

Names Default To Here(1);

//radiobox variables
enableList = {2,5};
rbItems = {"one", "two", "three", "four", "five"};
rb = Radio Box(rbItems);

//start as all disabled
For(i = 1, i <= N Items(rb << get items), i++,
	rb << enable item(i,0);
);

//enable based on enableList
For(i = 1, i <= N Items(enableList), i++,
	rb << enable item(enableList[i],1);
);
//change first selection to first in enableList (otherwise will be first in rbItems)
rb << Set(enableList[1], 1);

//create modal
ok_pressed = 0;
ex = New Window("Dialog() example",
	<<Modal,
	V List Box(
		rb,
		H List Box(
			Button Box("OK", ok_pressed = 1; rbSelection = rb << get),
			Button Box("Cancel", ok_pressed = 0)
		)
	)
);

If(ok_pressed == 1,
	show(rbSelection);
	show(rbItems[rbSelection]);
);
-Jarmo
Martin
Level V

Re: Enable Modal Radio Box Items based on predefined list

Thanks Jarmo!

 

This works exactly like I had hoped. I was not thinking of "pre setting up" the radio box, before showing it.

 

Martin