Here's some code which, when evaluated, types an expression in the cell below it:
FrontEndExecute@FrontEnd`SelectionMove[SelectedNotebook[],Next,CellContents];[email protected];
FrontEndExecute@FrontEnd`NotebookWrite[SelectedNotebook[],"1"];[email protected];
FrontEndExecute@FrontEnd`NotebookWrite[SelectedNotebook[],"+"]; [email protected];
FrontEndExecute@FrontEnd`NotebookWrite[SelectedNotebook[],"2"];[email protected];
FrontEndExecute@FrontEnd`SelectionMove[SelectedNotebook[],All,CellContents];[email protected];
FrontEndExecute@FrontEnd`NotebookApply[SelectedNotebook[],
FractionBox["\[SelectionPlaceholder]","\[Placeholder]"]];[email protected];
FrontEndExecute@FrontEnd`NotebookWrite[SelectedNotebook[], "3"];
Now I want to put it in a button, so I'll wrap it in Button["type stuff",...]
. But then it takes more than a second to see the full output due to something about the front end and updates and kernels and what not.
If instead I write Button["type stuff",...,Evaluator->None]
, I find out that Pause
is not a function available to the front end.
If I strip out all the Pause
s, then it works great -- there is some delay -- I would just like to slow it down.
Question
Is there a function available with no Evaluator
that can slow it down? Is there a way to switch Evaluator
s while a Button
function is running? Or should I stick with kernel evaluation only and do something with Dynamic
to get the progressive typing?
Extraneous questions:
- I tried to store the big typing code in a symbol, using
HoldForm
andReleaseHold
in theButton
-- I didn't manage to get it right, the front end couldn'tReleaseHold
the thing - I tried to have a wait parameter
t
instead of.2
, but again the front end couldn't reference the value oft
, and I couldn't figure out how to injectt
with aBlock
or something before creating theButton
- I tried to generate the code with a
Riffle[.../@Characters@"1+2",[email protected]]
, but how to turn the resulting list into an "input expression" -- no, an "input cell" with some newlines -- no, anInactive@CompoundExpression@@...
, but how toActivate
it without evaluating it... I'm at a loss.