View Full Version : UI alternate enable/disable checkBox
11-27-2011, 06:51 AM
Hi guys, so for example I have 2 checkBoxes, when A is checked, B will turn grey and vice versa. But how do I make them update without having to close window?
What I can think of is scriptJob at the moment, but I would love to hear how you guys do it. Thanks and appreciate for the help. :thumbsup:
-label "Checkbox A"
-onCommand "checkBox -edit -enable 0 checkBoxB"
-offCommand "checkBox -edit -enable 1 checkBoxB"
-label "Checkbox B"
-onCommand "checkBox -edit -enable 0 checkBoxA"
-offCommand "checkBox -edit -enable 1 checkBoxA"
The code above creates 2 checkboxes that "grey eachother out" whenever they are turned on and off.
The logical issue I have with your problem is this:
A is supposed to turn off B, B is supposed to turn off A. So say I check A, B gets greyed out. Now I want to check B (so I can grey out A). I can't do that, though, because B is greyed out and won't let me check it.
11-27-2011, 01:41 PM
Nyro, I guess you'll have to turn A off again first...
H2o-KiD, Nyro is correct, you achieve this by putting commands in the UI control's change command that alter the other control states. There is a slightly simpler way to do it though, with a single command that relies on the changing control state:
checkBox -label "Checkbox A"
-changeCommand "checkBox -edit -enable (!#1) checkBoxB"
checkBox -label "Checkbox B"
-changeCommand "checkBox -edit -enable (!#1) checkBoxA"
However, if you want multiple checkBoxes that turn each other off you may be better off with a radioButton.
Hehe Nathan you're right. I'm still confused how anyone would need such a functionality though. Perhaps the OP actually meant the checked state of the buttons? i.e. RadioBUtton functionality with checkboxes (for whatever reason).
H20, in that case, replace "-enable" with "-value". But yeah, radiobuttons would be the proper choice here.
11-27-2011, 02:33 PM
Yea, by using value instead of enable pretty much what I want to achieve where it acts like radioButton though radioButton will always be selecting something
Thanks for the help Nyro and nathaN :bounce:
11-27-2011, 02:33 PM
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.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.