0
$\begingroup$

In this code, one cannot close the dialog window:

{TogglerBar[Dynamic[x], Range[5]], Dynamic[x],  Dynamic[CreateDialog[x]]}

If I use DynamicModule this way, the dialog window will not pop up when it was closed and re-chosen some values.

{TogglerBar[Dynamic[y],Range[5]],Dynamic[y],DynamicModule[{y=y},CreateDialog[y]]}

So how to make the created dialog window could be closed and reopen when click to set different values by TogglerBar

$\endgroup$
  • $\begingroup$ In the first example you give, you can close the dialog. It just so happens a new one is created whenever you close an old one. You can notice this through the names changing in the output. In the second case, you forgot your Dynamic around CreateDialog if that was what you are asking about. Perhaps you are simply looking for CreateDialog[Dynamic@y] ? $\endgroup$ – jVincent May 16 '13 at 9:31
  • $\begingroup$ @jVincent Yeah, The first case just generate too many NotebookNojects. The second case: what I'm really looking for is How to Reopen the Dialog via Clicking in the TogglerBar. CreateDialog[Dynamic[y]] or Dynamic[CreateDialog[y]] seems doesn't work well. $\endgroup$ – HyperGroups May 16 '13 at 9:42
1
$\begingroup$

I'm not sure if this fully answers your question, but here is a method of using the Dynamic to check if a dialog is already open and reopen it if it has been closed:

DynamicModule[{nb = CreateDialog[Dynamic@y]},
 TogglerBar[
  Dynamic[y, (y = #;If[Not@MemberQ[Notebooks[], nb],nb = CreateDialog[Dynamic@y]]) &], 
 Range[5]]]
$\endgroup$
  • $\begingroup$ haha, that's right - thanks. $\endgroup$ – HyperGroups May 16 '13 at 10:04

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.