# Dynamically choosing which Manipulate controls to use

I have some stuff I would like to manipulate, using two different kinds of control, one at a time, using another variable as a switch. These controls are similar in principle to

Evaluate@(Sequence @@ {{controlA1, 0, 0.8}, {controlA2, 0, 2}})


and

{controlB, {-1, -1}, {1, 1}}


Therefore I tried using the code

Manipulate[

If[ChooseControlMode,
stuffA,
stuffB],

{{ChooseControlMode, False, "Choose control mode: "}, {True -> "A",

Dynamic@If[ChooseControlMode,
Evaluate@(Sequence @@ {{controlA1, 0, 0.8}, {controlA2, 0, 2}}),
{controlB, {-1, -1}, {1, 1}}]

]


However, for some reason MMA behaves as if what I meant to be my controls were actually simple text (and also splices the Sequence inside If, therefore preventing even this simple text from being displayed at the right time).

I also tried using something like

ReleaseHold@Dynamic@If[ChooseControlMode,
Hold@(Evaluate@(Sequence @@ {{controlA1, 0, 0.8}, {controlA2, 0,
2}})),
Hold@{controlB, {-1, -1}, {1, 1}}]


In this case instead I run into error

Manipulate::vsform: Manipulate argument ReleaseHold[...] does not have the correct form for a variable specification.

How can I get MMA to treat my input as additional controls and thus display them with their standard input (i.e., two Manipulators and a Slider2D)?

-

If you wrap each control with Control your code works as intended.

Manipulate[ If[ChooseControlMode, {stuffA, controlA1, controlA2}, {stuffB, controlB}],
{{ChooseControlMode, False,  "Choose control mode: "},
{True -> "A", False -> "B"}, PopupMenu},
Dynamic@If[ChooseControlMode,
(Column@{Control@{controlA1, 0, 0.8}, Control@{controlA2, 0, 2}}),
Control@{controlB, {-1, -1}, {1, 1}}]]


-

As I said in the comment, Enabled is really all you need:

DynamicModule[{control = True},
Dynamic@Manipulate[
Row[{Checkbox[Dynamic[control]], " a = ", a, " b = ", b}],
{a, 1, 10, Enabled -> control},
{b, 1, 10, Enabled -> ! control}
]
]


If you're looking to completely hide the unusable control, then replace Enabled->control with ControlType->If[control, Slider, None] for a and vice versa for b:

DynamicModule[{control = True},
Dynamic@Manipulate[
Row[{Checkbox[Dynamic[control]], " a = ", a, " b = ", b}], {a, 1,
10, ControlType -> If[control, Slider, None]}, {b, 1, 10,
ControlType -> If[control, None, Slider]}]]


As to your last question, put in whatever control types you were looking for instead of Slider and None.

-