Notifications
Clear all
[Closed] Check buttons
Sep 16, 2004 2:46 pm
Hello all,
Im writing a script which will have a couple of check buttons, I
ve used them in other scripts without problems but have run into a problem in this script. Basically When the user clicks on a check button, I want all the other check buttons in the script to return to an unchecked state.
Can anybody provide me with an example of how to write this, my recent attempts return errors.
Thanks for reading
Dan
2 Replies
1 Reply
If you want to mimic the way Radiobuttons work, you have to do something like this:
rollout test "Test"
(
checkbutton ckb_test01 "Checkbutton 1" width:150 checked:true
checkbutton ckb_test02 "Checkbutton 2" width:150
checkbutton ckb_test03 "Checkbutton 3" width:150
fn update_checkbuttons theButtonIndex =
(
--reset them all to unchecked:
ckb_test01.checked = ckb_test02.checked = ckb_test03.checked = false
--check the one corresponding to the index you passed:
case theButtonIndex of
(
1: ckb_test01.checked = true
2: ckb_test02.checked = true
3: ckb_test03.checked = true
)
)
on ckb_test01 changed state do
if state then --if checked then update all
update_checkbuttons 1
else --if unchecked, check it back (at least one should be checked!)
ckb_test01.checked = true
on ckb_test02 changed state do
if state then
update_checkbuttons 2
else
ckb_test02.checked = true
on ckb_test03 changed state do
if state then
update_checkbuttons 3
else
ckb_test03.checked = true
)
createDialog test
The above code does not allow a zero state where NO checkbutton is checked at any given time. If you want to allow the user to uncheck all, but have no more than one checked at any given time, you just have to remove the ELSE part of all 3 event handlers.