0
$\begingroup$

Here's a minimal example:

DynamicModule[{var = "", searchlist, randobutton},
 searchlist = 
  Table[StringJoin[RandomSample[CharacterRange["a", "z"], 7]], 40];
 randobutton = 
  Button["randotxt", 
   var = StringJoin[RandomSample[CharacterRange["a", "z"], 2]]];
 Deploy@Panel[#, ImageSize -> {Automatic, 300}] &@
        Column[{Dynamic[var, TrackedSymbols :> {var}],
                PopupWindow[Button["pop", Nothing], randobutton],
                randobutton,
                InputField[Dynamic[var, TrackedSymbols :> {var}], String, 
                        ContinuousAction -> True],
                Dynamic@Column[If[var === "",
                                {"[empty]"}, 
                                Select[searchlist, StringContainsQ[var]]]]
                }, Center]
 ]

If you press the main button, the InputField's string updates. If you press the popup's button, this does not occur. If the Dynamic[var] outside of the InputField did not have the TrackedSymbols option specified, it would exhibit the same behavior as the InputField, but the same fix does not work for the InputField.

How do I fix this bug?

Thank you very much for the help.

(edit: removed extra comma)

$\endgroup$
3
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$
    – bbgodfrey
    Aug 24 '21 at 21:19
  • $\begingroup$ Please take a look at InheritScope. $\endgroup$
    – Kuba
    Aug 25 '21 at 5:16
  • $\begingroup$ So, I replaced PopupWindow for CreateDialog[ __ ] which works on the front end. Thanks! @Kuba I'm curious why the TrackedSymbols change worked for the Dynamic[] but not the InputField[]. $\endgroup$
    – jWey
    Aug 25 '21 at 7:53
0
$\begingroup$

PopupWindow is the wrong function. You can use CreateDialog instead.

Here's an updated version:

DynamicModule[{...},
 ...
 ...Column[{
            Dynamic[var],
            Button["pop",  
                CreateDialog[
                    DynamicModule[{}, randobutton, InheritScope -> True]]],
            randobutton,
            InputField[Dynamic[var], ...],
            ...
            }]
]
$\endgroup$

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.