If I place an If
in the "body" of a Manipulate
as in:
Manipulate[tick;
Dynamic@If [ s1 == 1,
{"m1 ", Manipulator[Dynamic[m1, (m1 = #; tick = Not[tick]) &], {1, 4}], " ", Dynamic[m1]},
{"m2 ", Manipulator[Dynamic[m2, (m2 = #; tick = Not[tick]) &], {0, 1}], " ", Dynamic[m2]}
]
, TabView[{ "1" -> Grid[tabNumber = t1;(*Dynamic@*){ }],
"2" -> Grid[tabNumber = t2; {
{"s1 ", SetterBar[Dynamic[s1, (s1 = #; tick = Not[tick]) &], Range[2]], " ", Dynamic[s1]}
}]
}, Dynamic@tabNumber]
, {{tick, False}, None} , {{tabNumber, 1}, None}
, {{t1, 1}, None} , {{t2, 2}, None} , {{m1, 1}, None} , {{m2, 1}, None} , {{s1, 1}, None}
, TrackedSymbols :> {tick}, ControlPlacement -> Left
]
Then the selection of the s1 SetterBar
control switches the m1/m2 control in the Manipulate
display without any trouble:
I'd like to have this condition within the TabView
control, something like:
Manipulate[tick;
Dynamic@If[tabNumber == t1, Plot[x^2, {x, 0, 1}],
Plot[1 - x^2, {x, 0, 1}]]
, TabView[{
"1" ->(*Dynamic@*)Grid[tabNumber = t1;(*Dynamic@*){
(*Dynamic@*)If [ s1 == 1,
{"m1 ", Manipulator[ Dynamic[m1, (m1 = #; tick = Not[tick]) &], {1, 4}], " ", Dynamic[m1]},
{"m2 ", Manipulator[ Dynamic[m2, (m2 = #; tick = Not[tick]) &], {0, 1}], " ", Dynamic[m2]}
]
}],
"2" -> Grid[tabNumber = t2; {
{"s1 ", SetterBar[Dynamic[s1, (s1 = #; tick = Not[tick]) &], Range[2]], " ", Dynamic[s1]}
}]
}, Dynamic@tabNumber]
, {{tick, False}, None} , {{tabNumber, 1}, None}
, {{t1, 1}, None} , {{t2, 2}, None} , {{m1, 1}, None} , {{m2, 1}, None} , {{s1, 1}, None}
, TrackedSymbols :> {tick}, ControlPlacement -> Left
]
However, instead of one of the two desired controls showing up within the Tab, this produces
Grid[...]` text instead:
Is there a way to get the If condition in the Tab definition to evaluate before the TabView
? I have tried all the variations of Dynamic@
that I can think of, but they didn't help.