1
$\begingroup$

Nested Dialogs Experiment

The InsideDialog works as expected when invoked from the command line. When started as a button action inside OuterDialog, it takes a very long time to start up (many seconds). When a button is selected, the Inside dialog never returns. Is there a clean way to make this happen without messing with undocumented system internals?

InsideDialog[] := Module[{ans},
   ans = 0;
   CreateDialog[{Button["  A  "  , DialogReturn[ans = "A"]],
     Button["  B   "  , DialogReturn[ans = "B"]]}];
   While[ans == 0, Pause[0.2]];
   Return[ans];
   ];

InsideDialog[]

(* Out[26]= A *)

lessonlist = {
   "The Field Properties of \[DoubleStruckCapitalR] and \
\[DoubleStruckCapitalC]",
   "Introduction to Vectors and Vector Spaces",
   "Properties of Vector Arithmetic"};

 OutsideDialog[] := Module[{ans2},
   ans2 = 0;
   CreateDialog[
    Join[Button[#, DialogReturn[ans2 = InsideDialog[]], Method->"Queued"] & /@ 
      lessonlist, {Button["Close", DialogReturn[ans2 = 1]]}]];
   While[ans2 == 0, Pause[0.2]]; (* works OK if I do not wait here *)
   Return[ans2];
   ];

 OutsideDialog[]

(* Out[29]= 1 *)
$\endgroup$
  • $\begingroup$ As I understand the question, you wish to improve the performance of calling InsideDialog[] from OutsideDialog[]; however, your example does not demonstrate this behavior. Can you please clarify? $\endgroup$ – bobthechemist Jul 21 '14 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.