Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

share|improve this question
    
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] ? –  jVincent May 16 '13 at 9:31
    
@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. –  HyperGroups May 16 '13 at 9:42

1 Answer 1

up vote 1 down vote accepted

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]]]
share|improve this answer
    
haha, that's right - thanks. –  HyperGroups May 16 '13 at 10:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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