In a Manipulate
expression I have a slider control which has the Enabled
option
Enabled -> Dynamic[bool]
When bool
changes from False
to True
, the content pane in the output cell of the Manipulate
expression should change from
to
and the slider should go from disabled to enabled. The visual change takes place as expected, but the slider stays disabled.
Can anyone explain this behavior and suggest a way to fix it? Here is my code:
Manipulate[
Column[{If[bool,
content = {Black, Circle[], Red, Disk[{0., 0.}, r]},
RunScheduledTask[bool = True, {2}]];
Graphics[{content}, ImageSize -> 200],
bool}],
{{r, 0.5}, 0., 1., 0.1, Enabled -> Dynamic[bool],
Appearance -> "Labeled"},
{content, ControlType -> None},
ControlPlacement -> Bottom,
Initialization :>
(content = {Blue, Disk[]};
bool = False)]
I did test a slider that was not inside a Manipulate
expression and that had a dynamic Enabled
option. It worked fine. So why not in Manipulate
?
Update
I contacted Wolfram Research support and got back a suggestion for a work-around. It wasn't what I was hoping for, but it did lead to me something better than I had before. Only problem remaining is that the Mathematica editor's syntax checker doesn't like what I did. I'm living with that. Here are the details:
The question now boils down to: Can the syntax checker be propitiated?
Another Update
I received another response form WRI tech support.
After talking to our developers, it seems that your original method of using ControlType -> None should have worked after all. This now looks to be an issue of bad interaction between RunScheduledTask and DynamicModule. This issue has been filed into our database so that our development team can fix it at the earliest.
DynamicModule
variables were never designed to escape the confines of theDynamicModule
which scopes them, but scheduled tasks do quite a nice job of punching a hole in those confines. We should figure out how to deal with that problem, but haven't yet.Module
, on the other hand, creates an unexpected global (not local) variable which is scoped to the current kernel session. For this reason, mixingModule
andDynamic
orManipulate
is always a bad idea. That's why you get the syntax highlighting. $\endgroup$