PDA

View Full Version : Check buttons


djlane
09-16-2004, 02:46 PM
Hello all,

I`m 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

Bobo
09-16-2004, 04:34 PM
Hello all,

I`m 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

DanIf 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.

djlane
09-16-2004, 05:21 PM
Many Thanks for the help.

Cheers

Dan

CGTalk Moderation
01-19-2006, 07:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.