# How to perform DialogInput operation within Button

Can someone clarify how to perform a DialogInput operation within a Button? I wrote some code for that but it's not working.

Button["Enter value",
DialogInput[{name = ""},
Column[{InputField[Dynamic[name], String],
Button["Hi", Dynamic[name]]}]]]


My problem is this — when I run the above code, the given text is displayed but when I click on the button, the actual operation is not being carried out.

-
Please make a better effort to use proper capitalization and fewer ellipsis........ –  The Toad Jul 2 '12 at 18:35
But, the above DialogInput works as you expect and want when run in the notebook and not from a button? –  Rojo Jul 2 '12 at 18:38
I mean, the button issue is probably fixed by adding Method->"Queued" to the button, but even so, is that your only problem? –  Rojo Jul 2 '12 at 18:53
What is the "Hi" button supposed to do? –  Matariki Jul 2 '12 at 21:36
What is the meaning of Method-> "Queued" ?? –  subbu Jul 5 '12 at 5:34

## 1 Answer

As Rojo has pointed out, Method -> "Queued" can be used for the Button to wait for the dialog to appear, be evaluated, and return. I assume you want to use the value of name in some outer computation, so I forwarded it via a DialogReturn and therefore it is made global (while name inside DialogInput is local). Note that DialogReturn is the standard way to return values from a dialog.

Dynamic@output

Button["Enter value",
output = DialogInput[{name = ""},
Column[{InputField[Dynamic[name], String],
Button["Accept", DialogReturn[name]],
Button["Reject", DialogReturn[]]}]], Method -> "Queued"]


Accepting the input text updates the value of output in the first line (Out[1]).

-