Ok, this is pretty specific...
The objective is to use a TemplateBox
to format something that is programatically inserted with NotebookWrite
. That thing which is inserted is some dynamic control, an OpenerBox
.
So, for example:
(*Pause[3];*)NotebookWrite[InputNotebook[],
TemplateBox[{Dynamic[x]}, "blah",
DisplayFunction :> (OpenerBox[#] &)]]
Uncomment the Pause[3]
to try it. Run it and select something in another input cell.
The problem is, in this example, that the OpenerBox
doesn't open/close, or not until you convert the cell to cell expression and back to normal doing nothing, or until you cut and paste the OpenerBox
, or until you write something in the cell expression, etc... Point is, the cell expression is perfect but it doesn't work until you slap the FE a little bit...
What's going on? How can I use a TemplateBox
that gets pasted programatically to control some dynamic variable?