Class Dialog
- java.lang.Object
-
public class Dialog extends Window
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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.badlogic.gdx.scenes.scene2d.ui.Window
Window.WindowStyle
-
Nested classes/interfaces inherited from class com.badlogic.gdx.scenes.scene2d.ui.Table
Table.Debug, Table.DebugRect
-
-
Field Summary
Fields Modifier and Type Field Description protected InputListenerignoreTouchDown-
Fields inherited from class com.badlogic.gdx.scenes.scene2d.ui.Table
backgroundBottom, backgroundLeft, backgroundRight, backgroundTop, debugActorColor, debugCellColor, debugTableColor
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Dialogbutton(Button button)Adds the given button to the button table.Dialogbutton(Button button, java.lang.Object object)Adds the given button to the button table.Dialogbutton(java.lang.String text)Adds a text button to the button table.Dialogbutton(java.lang.String text, java.lang.Object object)Adds a text button to the button table.Dialogbutton(java.lang.String text, java.lang.Object object, TextButton.TextButtonStyle buttonStyle)Adds a text button to the button table.voidcancel()TablegetButtonTable()TablegetContentTable()voidhide()Hides the dialog.voidhide(Action action)Removes the dialog from the stage, restoring the previous keyboard and scroll focus, and adds the specified action to the dialog.Dialogkey(int keycode, java.lang.Object object)If this key is pressed,result(Object)is called with the specified object.protected voidresult(java.lang.Object object)Called when a button is clicked.voidsetObject(Actor actor, java.lang.Object object)protected voidsetStage(Stage stage)Called by the framework when this actor or any ascendant is added to a group that is in the stage.Dialogshow(Stage stage)Centers the dialog in the stage and callsshow(Stage, Action)with aActions.fadeIn(float, Interpolation)action.Dialogshow(Stage stage, Action action)Packsthe 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.Dialogtext(Label label)Adds the given Label to the content tableDialogtext(java.lang.String text)Adds a label to the content table.Dialogtext(java.lang.String text, Label.LabelStyle labelStyle)Adds a label to the content table.-
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Window
draw, drawBackground, drawStageBackground, getPrefWidth, getStyle, getTitleLabel, getTitleTable, hit, isDragging, isModal, isMovable, isResizable, keepWithinStage, newLabel, setKeepWithinStage, setModal, setMovable, setResizable, setResizeBorder, setStyle
-
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Table
add, add, add, add, add, add, add, align, background, background, bottom, center, clearChildren, clip, clip, columnDefaults, debug, debug, debugActor, debugAll, debugCell, debugTable, defaults, drawDebug, drawDebugBounds, getAlign, getBackground, getCell, getCells, getClip, getColumnMinWidth, getColumnPrefWidth, getColumns, getColumnWidth, getMinHeight, getMinWidth, getPadBottom, getPadBottomValue, getPadLeft, getPadLeftValue, getPadRight, getPadRightValue, getPadTop, getPadTopValue, getPadX, getPadY, getPrefHeight, getRow, getRowHeight, getRowMinHeight, getRowPrefHeight, getRows, getSkin, getTableDebug, invalidate, layout, left, pad, pad, pad, pad, padBottom, padBottom, padLeft, padLeft, padRight, padRight, padTop, padTop, removeActor, removeActor, removeActorAt, reset, right, row, setBackground, setBackground, setClip, setDebug, setRound, setSkin, stack, top
-
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
childrenChanged, getMaxHeight, getMaxWidth, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validate
-
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group
act, addActor, addActorAfter, addActorAt, addActorBefore, applyTransform, applyTransform, clear, clear, clearChildren, computeTransform, drawChildren, drawDebugChildren, findActor, getChild, getChildren, getCullingArea, hasChildren, isTransform, localToDescendantCoordinates, resetTransform, resetTransform, setCullingArea, setDebug, setTransform, swapActor, swapActor, toString
-
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, scaleChanged, screenToLocalCoordinates, setBounds, setColor, setColor, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront
-
-
-
-
Field Detail
-
ignoreTouchDown
protected InputListener ignoreTouchDown
-
-
Constructor Detail
-
Dialog
public Dialog(java.lang.String title, Skin skin)
-
Dialog
public Dialog(java.lang.String title, Skin skin, java.lang.String windowStyleName)
-
Dialog
public Dialog(java.lang.String title, Window.WindowStyle windowStyle)
-
-
Method Detail
-
setStage
protected void setStage(Stage stage)
Description copied from class:ActorCalled by the framework when this actor or any ascendant is added to a group that is in the stage.
-
getContentTable
public Table getContentTable()
-
getButtonTable
public Table getButtonTable()
-
text
public Dialog text(@Null java.lang.String text)
Adds a label to the content table. The dialog must have been constructed with a skin to use this method.
-
text
public Dialog text(@Null java.lang.String text, Label.LabelStyle labelStyle)
Adds a label to the content table.
-
button
public Dialog button(@Null java.lang.String text)
Adds a text button to the button table. Null will be passed toresult(Object)if this button is clicked. The dialog must have been constructed with a skin to use this method.
-
button
public Dialog button(@Null java.lang.String text, @Null java.lang.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- The object that will be passed toresult(Object)if this button is clicked. May be null.
-
button
public Dialog button(@Null java.lang.String text, @Null java.lang.Object object, TextButton.TextButtonStyle buttonStyle)
Adds a text button to the button table.- Parameters:
object- The object that will be passed toresult(Object)if this button is clicked. May be null.
-
button
public Dialog button(Button button, @Null java.lang.Object object)
Adds the given button to the button table.- Parameters:
object- The object that will be passed toresult(Object)if this button is clicked. May be null.
-
show
public Dialog show(Stage stage, @Null Action action)
Packsthe 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- May be null.
-
show
public Dialog show(Stage stage)
Centers the dialog in the stage and callsshow(Stage, Action)with aActions.fadeIn(float, Interpolation)action.
-
hide
public void hide(@Null 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- 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.
-
hide
public void hide()
Hides the dialog. Called automatically when a button is clicked. The default implementation fades out the dialog over 400 milliseconds.
-
key
public Dialog key(int keycode, @Null java.lang.Object object)
If this key is pressed,result(Object)is called with the specified object.- See Also:
Input.Keys
-
result
protected void result(@Null java.lang.Object object)
Called when a button is clicked. The dialog will be hidden after this method returns unlesscancel()is called.- Parameters:
object- The object specified when the button was added.
-
cancel
public void cancel()
-
-