How can I make this progress bar appears when I press Enter? The Button Evaluate works just fine, but when Enter is pressed it jumps the progress bar.
It would be easy if EventHandler could have Method-> "Queued", but is't not the case.
Here is my code:
DynamicModule[{output="",slowReport,progress,str,btnEval,enterAction,number,enterEval},
progress=ProgressIndicator[Dynamic[Clock[Infinity]],Indeterminate,ImageSize->280];
enterEval=EventHandler[#,{"ReturnKeyDown":>(output=progress;output=slowReport[])}]&;
btnEval=Button["Evaluate",(output=progress;output=slowReport[]),Method->"Queued"];
Dynamic@Panel@Column[{Row[{InputField[Dynamic[number], String]//enterEval,btnEval}]," ",output," "},Alignment->Center]
,Initialization:>
(
SetOptions[$FrontEndSession,DynamicEvaluationTimeout->10];
slowReport[]:=(Pause[1];ToExpression@number^2)
)
]
Here is what happens when Evaluate is pressed:



CellEventActions. – Kuba Dec 01 '13 at 14:13SetDelayeddoesn't work within the body of aDynamicModule. You need to useInitialization. – Mike Honeychurch Dec 02 '13 at 01:10Initialization. Tks. – Murta Dec 02 '13 at 23:08