###Manipulate version.
Manipulate version.
Manipulate[
Row@string
,
Column[{Dynamic[pop /@ Range[n] // Row, TrackedSymbols :> {n}],
SetterBar[
Dynamic[x,
If[# === "+", n++; string = Join[string, {"a"}], n--;
string = Most@string] &], {"+", "-"}]}]
,
{x, None},
{n, None},
{string, None}
,
Initialization :> (
pop[i_] :=
With[{j = i},
PopupMenu[Dynamic[string[[j]]], CharacterRange["a", "z"]]];
string = ConstantArray["a", 4];
n = 4;
)
]
DynamicModule version.
###DynamicModule version.
LetLet me not use Manipulate
, it is more handy with DynamicModule
in more complex cases:
DynamicModule[{ pop, x, n = 4, string = ConstantArray["a", 4] },
pop[i_] := With[{j = i},
PopupMenu[Dynamic[string[[j]]], CharacterRange["a", "z"]]
];
Panel@Column[{
Dynamic[pop /@ Range[n] // Row, TrackedSymbols :> {n}],
SetterBar[
Dynamic[x, If[# === "+", n++; string = Join[string, {"a"}],
n--; string = Most@string
] &], {"+", "-"}],
Dynamic@Row@string
}
]
]