com.badlogic.gdx.scenes.scene2d.ui
Class Dialog

java.lang.Object
  extended by com.badlogic.gdx.scenes.scene2d.Actor
      extended by com.badlogic.gdx.scenes.scene2d.Group
          extended by com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
              extended by com.badlogic.gdx.scenes.scene2d.ui.Table
                  extended by com.badlogic.gdx.scenes.scene2d.ui.Window
                      extended by com.badlogic.gdx.scenes.scene2d.ui.Dialog
All Implemented Interfaces:
Cullable, Layout

public class Dialog
extends Window

Displays a dialog, which is a modal window containing a content table with a button table underneath it. 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

Nested Class Summary
 
Nested classes/interfaces inherited from class com.badlogic.gdx.scenes.scene2d.ui.Window
Window.WindowStyle
 
Field Summary
static float fadeDuration
          The time in seconds that dialogs will fade in and out.
 
Constructor Summary
Dialog(String title, Skin skin)
           
Dialog(String title, Skin skin, String windowStyleName)
           
Dialog(String title, Window.WindowStyle windowStyle)
           
 
Method Summary
 Dialog button(Button button)
          Adds the given button to the button table.
 Dialog button(Button button, Object object)
          Adds the given button to the button table.
 Dialog button(String text)
          Adds a text button to the button table.
 Dialog button(String text, Object object)
          Adds a text button to the button table.
 Dialog button(String text, Object object, TextButton.TextButtonStyle buttonStyle)
          Adds a text button to the button table.
 void cancel()
           
 Table getButtonTable()
           
 Table getContentTable()
           
 void hide()
          Hides the dialog.
 Dialog key(int keycode, Object object)
          If this key is pressed, result(Object) is called with the specified object.
 void setObject(Actor actor, Object object)
           
 Dialog show(Stage stage)
          Packs the dialog and adds it to the stage, centered.
 Dialog text(Label label)
          Adds the given Label to the content table
 Dialog text(String text)
          Adds a label to the content table.
 Dialog text(String text, Label.LabelStyle labelStyle)
          Adds a label to the content table.
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Window
draw, getPrefWidth, getStyle, getTitle, hit, isDragging, setKeepWithinStage, setModal, setMovable, setStyle, setTitle, setTitleAlignment
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Table
add, add, add, add, add, add, align, bottom, center, clearChildren, columnDefaults, debug, debug, debugCell, debugTable, debugWidget, defaults, drawDebug, getAlign, getBackground, getCell, getCells, getClip, getDebug, getMinHeight, getMinWidth, getPadBottom, getPadBottomValue, getPadLeft, getPadLeftValue, getPadRight, getPadRightValue, getPadTop, getPadTopValue, getPadX, getPadY, getPrefHeight, getRow, invalidate, layout, left, pad, pad, pad, pad, padBottom, padBottom, padLeft, padLeft, padRight, padRight, padTop, padTop, removeActor, reset, right, row, setBackground, setBackground, setClip, setRound, setSkin, stack, top
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
getMaxHeight, getMaxWidth, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, validate
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group
act, addActor, addActorAfter, addActorAt, addActorBefore, clear, findActor, getChildren, hasChildren, isTransform, localToDescendantCoordinates, print, setCullingArea, setTransform, swapActor, swapActor
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
addAction, addCaptureListener, addListener, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, fire, getActions, getCaptureListeners, getColor, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getWidth, getX, getY, getZIndex, hasParent, isAscendantOf, isDescendantOf, isVisible, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, notify, parentToLocalCoordinates, remove, removeAction, removeCaptureListener, removeListener, rotate, scale, scale, screenToLocalCoordinates, setBounds, setColor, setColor, setHeight, setName, setOrigin, setOriginX, setOriginY, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setVisible, setWidth, setX, setY, setZIndex, size, size, stageToLocalCoordinates, toBack, toFront, toString, translate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fadeDuration

public static float fadeDuration
The time in seconds that dialogs will fade in and out. Set to zero to disable fading.

Constructor Detail

Dialog

public Dialog(String title,
              Skin skin)

Dialog

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

Dialog

public Dialog(String title,
              Window.WindowStyle windowStyle)
Method Detail

getContentTable

public Table getContentTable()

getButtonTable

public Table getButtonTable()
Overrides:
getButtonTable in class Window

text

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.


text

public Dialog text(String text,
                   Label.LabelStyle labelStyle)
Adds a label to the content table.


text

public Dialog text(Label label)
Adds the given Label to the content table


button

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.


button

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 - The object that will be passed to result(Object) if this button is clicked. May be null.

button

public Dialog button(String text,
                     Object object,
                     TextButton.TextButtonStyle buttonStyle)
Adds a text button to the button table.

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

button

public Dialog button(Button button)
Adds the given button to the button table.


button

public Dialog button(Button button,
                     Object object)
Adds the given button to the button table.

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

show

public Dialog show(Stage stage)
Packs the dialog and adds it to the stage, centered.


hide

public void hide()
Hides the dialog. Called automatically when a button is clicked. The default implementation fades out the dialog over fadeDuration seconds and then removes it from the stage.


setObject

public void setObject(Actor actor,
                      Object object)

key

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

See Also:
Input.Keys

cancel

public void cancel()


Copyright © 2013. All Rights Reserved.