APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.scenes.scene2d.ui

public Class Dialog

extends Window
Class Inheritance
Static Imports
com.badlogic.gdx.scenes.scene2d.actions.Actions.*

Displays a dialog, which is a window with a title, a content table, and a button table. Methods are provided to add a label to the content table and buttons to the button table, but any widgets can be added. When a button is clicked, result(Object) is called and the dialog is removed from the stage.
Author
Nathan Sweet

Field Summary

Modifier and TypeField and Description
pack-priv Table
pack-priv boolean
pack-priv Table
pack-priv FocusListener
protected InputListener
pack-priv Actor
pack-priv Actor
private Skin
pack-priv ObjectMap<Actor, Object>
Inherited from com.badlogic.gdx.scenes.scene2d.ui.Window:
draggingdrawTitleTableedgeisModalisMovableisResizablekeepWithinStageresizeBordertitleLabeltitleTable

Constructor Summary

AccessConstructor and Description
public
Dialog(String title, Skin skin)

public
Dialog(String title, Skin skin, String windowStyleName)

public
Dialog(String title, Window.WindowStyle windowStyle)

Method Summary

Modifier and TypeMethod and Description
public Dialog
button(String text)

Adds a text button to the button table.

public Dialog
button(String text, Object
The object that will be passed to result(Object) if this button is clicked. May be null.
object
)

Adds a text button to the button table.

public Dialog
button(String text, Object
The object that will be passed to result(Object) if this button is clicked. May be null.
object
,
TextButton.TextButtonStyle buttonStyle)

Adds a text button to the button table.

public Dialog
button(Button button)

Adds the given button to the button table.

public Dialog
button(Button button, Object
The object that will be passed to result(Object) if this button is clicked. May be null.
object
)

Adds the given button to the button table.

public void
public Table
public Table
public void
hide(Action
If null, the dialog is removed immediately. Otherwise, the dialog is removed when the action completes. The dialog will not respond to touch down events during the action.
action
)

Removes the dialog from the stage, restoring the previous keyboard and scroll focus, and adds the specified action to the dialog.

public void
hide()

Hides the dialog.

private void
public Dialog
key(final int keycode, final Object object)

If this key is pressed, result(Object) is called with the specified object.

protected void
result(Object
The object specified when the button was added.
object
)

Called when a button is clicked.

public void
setObject(Actor actor, Object object)

protected void
setStage(Stage stage)

Overrides com.badlogic.gdx.scenes.scene2d.Group.setStage.

Called by the framework when this actor or any ascendant is added to a group that is in the stage.

public Dialog
show(Stage stage, Action
May be null.
action
)

Packs the dialog (but doesn't set the position), adds it to the stage, sets it as the keyboard and scroll focus, clears any actions on the dialog, and adds the specified action to it.

public Dialog
show(Stage stage)

Centers the dialog in the stage and calls show(Stage, Action) with a Actions#fadeIn(float, Interpolation) action.

public Dialog
text(String text)

Adds a label to the content table.

public Dialog
text(String text, Label.LabelStyle labelStyle)

Adds a label to the content table.

public Dialog
text(Label label)

Adds the given Label to the content table

Inherited from com.badlogic.gdx.scenes.scene2d.ui.Window:
drawdrawBackgrounddrawStageBackgroundgetPrefWidthgetStylegetTitleLabelgetTitleTablehitisDraggingisModalisMovableisResizablekeepWithinStagenewLabelsetKeepWithinStagesetModalsetMovablesetResizablesetResizeBordersetStyle

Field Detail

buttonTableback to summary
pack-priv Table buttonTable
cancelHideback to summary
pack-priv boolean cancelHide
contentTableback to summary
pack-priv Table contentTable
focusListenerback to summary
pack-priv FocusListener focusListener
ignoreTouchDownback to summary
protected InputListener ignoreTouchDown
previousKeyboardFocusback to summary
pack-priv Actor previousKeyboardFocus
previousScrollFocusback to summary
pack-priv Actor previousScrollFocus
skinback to summary
private Skin skin

Hides com.badlogic.gdx.scenes.scene2d.ui.Table.skin.

Annotations
@Null
valuesback to summary
pack-priv ObjectMap<Actor, Object> values

Constructor Detail

Dialogback to summary
public Dialog(String title, Skin skin)
Dialogback to summary
public Dialog(String title, Skin skin, String windowStyleName)
Dialogback to summary
public Dialog(String title, Window.WindowStyle windowStyle)

Method Detail

buttonback to summary
public Dialog button(String text)

Adds a text button to the button table. Null will be passed to result(Object) if this button is clicked. The dialog must have been constructed with a skin to use this method.

buttonback to summary
public Dialog button(String text, Object object)

Adds a text button to the button table. The dialog must have been constructed with a skin to use this method.

Parameters
object:Object

The object that will be passed to result(Object) if this button is clicked. May be null.

buttonback to summary
public Dialog button(String text, Object object, TextButton.TextButtonStyle buttonStyle)

Adds a text button to the button table.

Parameters
object:Object

The object that will be passed to result(Object) if this button is clicked. May be null.

buttonback to summary
public Dialog button(Button button)

Adds the given button to the button table.

buttonback to summary
public Dialog button(Button button, Object object)

Adds the given button to the button table.

Parameters
object:Object

The object that will be passed to result(Object) if this button is clicked. May be null.

cancelback to summary
public void cancel()
getButtonTableback to summary
public Table getButtonTable()
getContentTableback to summary
public Table getContentTable()
hideback to summary
public void hide(Action action)

Removes the dialog from the stage, restoring the previous keyboard and scroll focus, and adds the specified action to the dialog.

Parameters
action:Action

If null, the dialog is removed immediately. Otherwise, the dialog is removed when the action completes. The dialog will not respond to touch down events during the action.

hideback to summary
public void hide()

Hides the dialog. Called automatically when a button is clicked. The default implementation fades out the dialog over 400 milliseconds.

initializeback to summary
private void initialize()
keyback to summary
public Dialog key(final int keycode, final Object object)

If this key is pressed, result(Object) is called with the specified object.

See Also
Keys
resultback to summary
protected void result(Object object)

Called when a button is clicked. The dialog will be hidden after this method returns unless cancel() is called.

Parameters
object:Object

The object specified when the button was added.

setObjectback to summary
public void setObject(Actor actor, Object object)
setStageback to summary
protected void setStage(Stage stage)

Overrides com.badlogic.gdx.scenes.scene2d.Group.setStage.

Doc from com.badlogic.gdx.scenes.scene2d.Actor.setStage.

Called by the framework when this actor or any ascendant is added to a group that is in the stage.

showback to summary
public Dialog show(Stage stage, Action action)

Packs the dialog (but doesn't set the position), adds it to the stage, sets it as the keyboard and scroll focus, clears any actions on the dialog, and adds the specified action to it. The previous keyboard and scroll focus are remembered so they can be restored when the dialog is hidden.

Parameters
action:Action

May be null.

showback to summary
public Dialog show(Stage stage)

Centers the dialog in the stage and calls show(Stage, Action) with a Actions#fadeIn(float, Interpolation) action.

textback to summary
public Dialog text(String text)

Adds a label to the content table. The dialog must have been constructed with a skin to use this method.

textback to summary
public Dialog text(String text, Label.LabelStyle labelStyle)

Adds a label to the content table.

textback to summary
public Dialog text(Label label)

Adds the given Label to the content table