I've attempted to use TabView
in a Manipulate
to display sets of controls and alter a "display" associated with each set of controls:
Manipulate[
tick;
Dynamic@Switch[ tabNumber
, tab1, Plot[x^2, {x, 0, 1}]
, tab2, Plot[1 - x^2, {x, 0, 1}]
, _, Plot[Sin[x] E^(-x), {x, 0, 1}]
]
, Dynamic@TabView[
{
"1" -> Column[ tabNumber = tab1 ; { Row[{ "1 selected"}] } ],
"2" -> Column[ tabNumber = tab2 ; Beep[] ; { Row[{ "2 selected"}] } ],
"3" -> Column[ tabNumber = tab3 ; Beep[] ; { Row[{ "3 selected"}] } ]
}, Dynamic @tabNumber
]
, {{tick, False}, None}
, {{tabNumber, 1}, None}
, {{tab1, 1}, None} , {{tab2, 2}, None} , {{tab3, 3}, None}
, TrackedSymbols :> {tick}
, ControlPlacement -> Left
]
For interactive purposes, this works as desired. However, when the Manipulate
is initially evaluated the tabs cycle from my default tab to the final tab. This is also seen in copies of the output cell (i.e. for the snapshot and thumbnail in a Wolfram demo selection). This prevents me from retaining the tabs that I'd like to display in each of the snapshots, which had been picked to display representative content.
For that initial evaluation it seems that all the tabs get cycled through, despite the fact that I'd set an initial tab number. For example, the code above shows tab 3 as selected:
The two Beep[]
calls above are also heard when the Manipulate
initially runs.
The end result is that something appears to be magically auto-selecting each of the tabs in sequence, but I think my method of recording which tab I am on, so that I can make my output panel adjust, is having a side effect of altering my tabNumber variable when the TabView
is first evaluated.
Presuming that is what is happening, how can I record my current tabNumber without the side effects seen above?