# Why doesn't the FileNameSetter button work in my DialogInput?

I am new to Mathematica, so it's probably a small error but I can't figure it out.

Here is the code :

DialogInput[{TextCell["Choose your folder:"], InputField[Dynamic[x]],
FileNameSetter[Dynamic[x], "Directory"],
DefaultButton[DialogReturn[x]]}]


When I click on the browse button, nothing happen. Then, when I click on OK, the file system browsing window appears.

-

Another way to get around the fact that the kernel will block until DialogReturn is evaluated is to use Method -> "Preemptive":

DialogInput[{TextCell["Choose your folder:"],
InputField[Dynamic[x]],
FileNameSetter[Dynamic[x], "Directory", Method -> "Preemptive"],
DefaultButton[DialogReturn[x]]}]

-
It seem that now Automatic method know what to. –  Kuba Feb 2 at 9:18
@Kuba It seems to work in V9, too, even though it gives an error message. No error message in V10. (No change indicated in the documentation, so they consider this a minor fix, I guess.) Odd that the default behavior is not the same as Automatic. –  Michael E2 Feb 2 at 11:14
Yes, it seems you have to know what you want and always place it explicitly if you want things to work :) –  Kuba Feb 2 at 11:16

Mathematica "freezes" until you press the dialog return. This is by design for DialogInput as far as I know. So instead use CreateDialog

CreateDialog[{TextCell["Choose your folder:"], InputField[Dynamic[x]],
FileNameSetter[Dynamic[x], "Directory"],
DefaultButton[]}]

-
That's what I wanted to use. However, CreateDialog doesn't "freeze" and so the code go on without waiting for the input (I tried Modal->True but it didn't work in this case). –  Stef Aug 13 '13 at 13:57