zyd199012
(Yode Japhe)
1
I want to make a “slectAll” and “slectNone” button in CheckboxBar,this is current method
DynamicModule[{x},
First[{CheckboxBar[
Dynamic[x], {1, 2, 3, 4 -> "SelectAll", 5 -> "SelectNone"}],
If[MemberQ[x, 4], x = {1, 2, 3}, If[MemberQ[x, 5], x = {}]]}]]
But it’s seem the If don’t work..
kubapod
(Kuba Podkalicki)
2
Well, First from {CheckboxBar[ Dynamic[x], {1, 2, 3, 4 -> "SelectAll", 5 -> "SelectNone"}], If[MemberQ[x, 4], x = {1, 2, 3}, If[MemberQ[x, 5], x = {}]]} is just CheckboxBar[ Dynamic[x], {1, 2, 3, 4 -> "SelectAll", 5 -> "SelectNone"}]. But let’s leave this aside.
CheckboxBar has some non trivial action behind so in this case the DynamicWrapper will be the most convenient:
DynamicModule[{x}
, DynamicWrapper[
CheckboxBar[ Dynamic[x], {1, 2, 3, 4 -> "SelectAll", 5 -> "SelectNone"}]
, If[MemberQ[x, 4], x = {1, 2, 3}, If[MemberQ[x, 5], x = {}]]
]
]