({{, (RefLink[CreateDialog, paclet:ref/CreateDialog])[expr] 
creates a dialog notebook containing expr and opens it in the front end.}, {, (RefLink[CreateDialog, paclet:ref/CreateDialog])[expr,obj] 
replaces the notebook represented by the notebook object obj with the one obtained from expr.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[CreateDialog, paclet:ref/CreateDialog]) by default creates a notebook with options set so as to be suitable for the appearance and behavior of a typical dialog box. The option settings include (RefLink[Deployed, paclet:ref/Deployed])->(RefLink[True, paclet:ref/True]), (RefLink[ShowCellBracket, paclet:ref/ShowCellBracket])->(RefLink[False, paclet:ref/False]), (RefLink[WindowFloating, paclet:ref/WindowFloating])->(RefLink[False, paclet:ref/False]) and (RefLink[WindowSize, paclet:ref/WindowSize])->(RefLink[All, paclet:ref/All]).

Dialog notebooks created by (RefLink[CreateDialog, paclet:ref/CreateDialog]) are by default opened in the middle of the main display screen. Explicit settings for (RefLink[WindowMargins, paclet:ref/WindowMargins]) override this.

(RefLink[CreateDialog, paclet:ref/CreateDialog])[expr] by default puts expr into a single output cell.

If expr is a complete notebook expression, (RefLink[CreateDialog, paclet:ref/CreateDialog])[expr] creates an open notebook corresponding to this expression.

If expr is a cell or list of cells, (RefLink[CreateDialog, paclet:ref/CreateDialog])[expr] creates a notebook consisting of this cell or cells.

(RefLink[CreateDialog, paclet:ref/CreateDialog]) can take any notebook option.

If no explicit setting is given for (RefLink[WindowTitle, paclet:ref/WindowTitle]), no name will be displayed for a dialog.

The additional option (RefLink[Modal, paclet:ref/Modal]) specifies whether the dialog created by (RefLink[CreateDialog, paclet:ref/CreateDialog]) should be modal.

With the default setting (RefLink[Modal, paclet:ref/Modal])->(RefLink[False, paclet:ref/False]), other windows can be used even when the dialog is open. With (RefLink[Modal, paclet:ref/Modal])->(RefLink[True, paclet:ref/True]), no other Wolfram System windows can be used until the dialog has been closed. If there is no mechanism for closing the dialog, the Wolfram System will effectively freeze.

If (RefLink[DialogReturn, paclet:ref/DialogReturn]) is executed, for example as a result of clicking a button, within the window created by (RefLink[CreateDialog, paclet:ref/CreateDialog]), then the window will be closed.

In dialogs created with (RefLink[CreateDialog, paclet:ref/CreateDialog]), pressing (Key0[MacOSXreturnenter]) is effectively equivalent to clicking the (RefLink[DefaultButton, paclet:ref/DefaultButton]), and (Key0[esc]) to clicking the (RefLink[CancelButton, paclet:ref/CancelButton]).

If the dialog contains no (RefLink[DefaultButton, paclet:ref/DefaultButton]) or (RefLink[CancelButton, paclet:ref/CancelButton]), pressing (Key0[MacOSXreturnenter]) or (Key0[esc]) will close the dialog without taking any other action.

(RefLink[CreateDialog, paclet:ref/CreateDialog]) returns a (RefLink[NotebookObject, paclet:ref/NotebookObject]) corresponding to the notebook it creates.

(RefLink[CreateDialog, paclet:ref/CreateDialog])[expr,obj] overwrites whatever data was contained in the notebook represented by the notebook object obj.

OpenersPrimaryExamplesSection(Spacer1)Examples  (10)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Make a dialog notebook:

CreateDialog[{TextCell["Click OK to close"],DefaultButton[]}];

Make a dialog notebook that accepts input text:

CreateDialog[{TextCell["Enter a name: "],InputField[Dynamic[nm],String],DefaultButton[DialogReturn[ret=nm]]}];

Type something in the input field:

Click OK to assign the input to ret:

ret

OpenersExampleSection1(Spacer1)Scope  (2)

Put up a dialog window for setting a value for u:

CreateDialog[Manipulate[Button["press me",u=x],{x,0,1}]];

Moving the slider changes the value of the (RefLink[Manipulate, paclet:ref/Manipulate]) variable x:

Click the button to set u:

u

Create a modal dialog, which blocks interactions with other open notebooks:

CreateDialog[{TextCell["Click OK to close"],DefaultButton[]},Modal->True];

OpenersExampleSection2(Spacer1)Options  (4)

OpenersExampleSubsection0(Spacer1)Background  (1)

Choose a background:

CreateDialog[{TextCell["Click OK to close"],DefaultButton[]},Background->LightBlue];

OpenersExampleSubsection1(Spacer1)Enabled  (1)

Create a dialog with user interactivity disabled:

nb=CreateDialog[{TextCell["x"],Slider[Dynamic[x],{0,1}]},Enabled->False];

Enable user interactivity:

SetOptions[nb,Enabled->True];

OpenersExampleSubsection2(Spacer1)WindowMargins  (1)

Place a dialog window at the upper left of the screen:

CreateDialog[{TextCell["Click OK to close"],DefaultButton[]},WindowMargins->{{0,Automatic},{Automatic,0}}];

OpenersExampleSubsection3(Spacer1)WindowTitle  (1)

CreateDialog[{TextCell["Click OK to close"],DefaultButton[]},WindowTitle->"Success"];

OpenersExampleSection3(Spacer1)Applications  (1)

Create a dialog window for manipulating a graphics object:

CreateDialog[DynamicModule[{a="○",ctr={.5,.5}},Column[{SetterBar[Dynamic[a],{"○","●","□","■"}],Slider2D[Dynamic[ctr]],Dynamic[Graphics[Text[a,ctr],ImageSize->140,Background->White,PlotRange->{{0,1},{0,1}}]],DefaultButton[]}]]];

OpenersExampleSection4(Spacer1)Properties & Relations  (1)

To create a dialog that blocks kernel evaluations, use (RefLink[DialogInput, paclet:ref/DialogInput]):

CreateDialog[{TextCell["Click OK to close"],DefaultButton[]}];

DialogInput[{TextCell["Click OK to close"],DefaultButton[]}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[MessageDialog, paclet:ref/MessageDialog])  ▪  (RefLink[ChoiceDialog, paclet:ref/ChoiceDialog])  ▪  (RefLink[DialogInput, paclet:ref/DialogInput])  ▪  (RefLink[CreatePalette, paclet:ref/CreatePalette])  ▪  (RefLink[Button, paclet:ref/Button])  ▪  (RefLink[DefaultButton, paclet:ref/DefaultButton])  ▪  (RefLink[CancelButton, paclet:ref/CancelButton])  ▪  (RefLink[DialogReturn, paclet:ref/DialogReturn])  ▪  (RefLink[CreateDocument, paclet:ref/CreateDocument])  ▪  (RefLink[CreateWindow, paclet:ref/CreateWindow])  ▪  (RefLink[NotebookClose, paclet:ref/NotebookClose])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Creating Dialog Boxes, paclet:tutorial/CreatingDialogBoxes])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Dialog Boxes, paclet:guide/DialogBoxes])}, {▪(RefLinkPlain[Custom Interface Construction, paclet:guide/CustomInterfaceConstruction])}, {▪(RefLinkPlain[Standalone Interfaces, paclet:guide/StandAloneInterfaces])}})}})