Class TypingDialog

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

public class TypingDialog
extends TypingWindow
Displays a dialog, which is a TypingWindow with a TypingLabel for a title, a content table, and a button table. Methods are provided to add a TextraLabel or TypingLabel 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.Table

    com.badlogic.gdx.scenes.scene2d.ui.Table.Debug, com.badlogic.gdx.scenes.scene2d.ui.Table.DebugRect
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected com.badlogic.gdx.scenes.scene2d.InputListener ignoreTouchDown  

    Fields inherited from class com.github.tommyettinger.textra.TextraWindow

    dragging, edge, font

    Fields inherited from class com.badlogic.gdx.scenes.scene2d.ui.Table

    backgroundBottom, backgroundLeft, backgroundRight, backgroundTop, debugActorColor, debugCellColor, debugTableColor
  • Constructor Summary

    Constructors
    Constructor Description
    TypingDialog​(java.lang.String title, com.badlogic.gdx.scenes.scene2d.ui.Skin skin)  
    TypingDialog​(java.lang.String title, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, Font replacementFont)  
    TypingDialog​(java.lang.String title, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, java.lang.String windowStyleName)  
    TypingDialog​(java.lang.String title, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, java.lang.String windowStyleName, Font replacementFont)  
    TypingDialog​(java.lang.String title, com.badlogic.gdx.scenes.scene2d.ui.Window.WindowStyle windowStyle)  
    TypingDialog​(java.lang.String title, com.badlogic.gdx.scenes.scene2d.ui.Window.WindowStyle windowStyle, Font replacementFont)  
  • Method Summary

    Modifier and Type Method Description
    TypingDialog button​(com.badlogic.gdx.scenes.scene2d.ui.Button button)
    Adds the given button to the button table.
    TypingDialog button​(com.badlogic.gdx.scenes.scene2d.ui.Button button, java.lang.Object object)
    Adds the given button to the button table.
    TypingDialog button​(java.lang.String text)
    Adds a text button to the button table.
    TypingDialog button​(java.lang.String text, java.lang.Object object)
    Adds a text button to the button table.
    TypingDialog button​(java.lang.String text, java.lang.Object object, com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle buttonStyle)
    Adds a text button to the button table.
    void cancel()  
    com.badlogic.gdx.scenes.scene2d.ui.Table getButtonTable()  
    com.badlogic.gdx.scenes.scene2d.ui.Table getContentTable()  
    void hide()
    Hides the dialog.
    void hide​(com.badlogic.gdx.scenes.scene2d.Action action)
    Removes the dialog from the stage, restoring the previous keyboard and scroll focus, and adds the specified action to the dialog.
    TypingDialog key​(int keycode, java.lang.Object object)
    If this key is pressed, result(Object) is called with the specified object.
    protected TextraLabel newLabel​(java.lang.String text, com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle style)  
    protected TextraLabel newLabel​(java.lang.String text, Font font, com.badlogic.gdx.graphics.Color color)  
    protected TypingLabel newTypingLabel​(java.lang.String text, com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle style)  
    protected TypingLabel newTypingLabel​(java.lang.String text, Font font, com.badlogic.gdx.graphics.Color color)  
    protected void result​(java.lang.Object object)
    Called when a button is clicked.
    void setObject​(com.badlogic.gdx.scenes.scene2d.Actor actor, java.lang.Object object)  
    protected void setStage​(com.badlogic.gdx.scenes.scene2d.Stage stage)  
    TypingDialog show​(com.badlogic.gdx.scenes.scene2d.Stage stage)
    Centers the dialog in the stage and calls show(Stage, Action) with a Actions.fadeIn(float, Interpolation) action.
    TypingDialog show​(com.badlogic.gdx.scenes.scene2d.Stage stage, com.badlogic.gdx.scenes.scene2d.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.
    TypingDialog text​(TextraLabel label)
    Adds the given TextraLabel to the content table.
    TypingDialog text​(java.lang.String text)
    Adds a TextraLabel to the content table.
    TypingDialog text​(java.lang.String text, com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle labelStyle)
    Adds a TextraLabel to the content table.
    TypingDialog text​(java.lang.String text, Font font)
    Adds a TextraLabel to the content table.
    TypingDialog text​(java.lang.String text, Font font, com.badlogic.gdx.graphics.Color color)
    Adds a TextraLabel to the content table.
    TypingDialog typing​(TypingLabel label)
    Adds the given TypingLabel to the content table.
    TypingDialog typing​(java.lang.String text)
    Adds a TypingLabel to the content table.
    TypingDialog typing​(java.lang.String text, com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle labelStyle)
    Adds a TypingLabel to the content table.
    TypingDialog typing​(java.lang.String text, Font font)
    Adds a TypingLabel to the content table.
    TypingDialog typing​(java.lang.String text, Font font, com.badlogic.gdx.graphics.Color color)
    Adds a TypingLabel to the content table.

    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • ignoreTouchDown

      protected com.badlogic.gdx.scenes.scene2d.InputListener ignoreTouchDown
  • Constructor Details

    • TypingDialog

      public TypingDialog​(java.lang.String title, com.badlogic.gdx.scenes.scene2d.ui.Skin skin)
    • TypingDialog

      public TypingDialog​(java.lang.String title, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, java.lang.String windowStyleName)
    • TypingDialog

      public TypingDialog​(java.lang.String title, com.badlogic.gdx.scenes.scene2d.ui.Window.WindowStyle windowStyle)
    • TypingDialog

      public TypingDialog​(java.lang.String title, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, Font replacementFont)
    • TypingDialog

      public TypingDialog​(java.lang.String title, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, java.lang.String windowStyleName, Font replacementFont)
    • TypingDialog

      public TypingDialog​(java.lang.String title, com.badlogic.gdx.scenes.scene2d.ui.Window.WindowStyle windowStyle, Font replacementFont)
  • Method Details

    • newLabel

      protected TextraLabel newLabel​(java.lang.String text, com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle style)
      Overrides:
      newLabel in class TypingWindow
    • newLabel

      protected TextraLabel newLabel​(java.lang.String text, Font font, com.badlogic.gdx.graphics.Color color)
      Overrides:
      newLabel in class TypingWindow
    • newTypingLabel

      protected TypingLabel newTypingLabel​(java.lang.String text, com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle style)
    • newTypingLabel

      protected TypingLabel newTypingLabel​(java.lang.String text, Font font, com.badlogic.gdx.graphics.Color color)
    • setStage

      protected void setStage​(com.badlogic.gdx.scenes.scene2d.Stage stage)
      Overrides:
      setStage in class com.badlogic.gdx.scenes.scene2d.Group
    • getContentTable

      public com.badlogic.gdx.scenes.scene2d.ui.Table getContentTable()
    • getButtonTable

      public com.badlogic.gdx.scenes.scene2d.ui.Table getButtonTable()
    • text

      public TypingDialog text​(@Null java.lang.String text)
      Adds a TextraLabel to the content table. The dialog must have been constructed with a skin to use this method.
    • text

      public TypingDialog text​(@Null java.lang.String text, com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle labelStyle)
      Adds a TextraLabel to the content table.
    • text

      public TypingDialog text​(@Null java.lang.String text, Font font)
      Adds a TextraLabel to the content table.
    • text

      public TypingDialog text​(@Null java.lang.String text, Font font, com.badlogic.gdx.graphics.Color color)
      Adds a TextraLabel to the content table.
    • text

      public TypingDialog text​(TextraLabel label)
      Adds the given TextraLabel to the content table.
      Parameters:
      label - a non-null TextraLabel
    • typing

      public TypingDialog typing​(@Null java.lang.String text)
      Adds a TypingLabel to the content table. The dialog must have been constructed with a skin to use this method.
    • typing

      public TypingDialog typing​(@Null java.lang.String text, com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle labelStyle)
      Adds a TypingLabel to the content table.
    • typing

      public TypingDialog typing​(@Null java.lang.String text, Font font)
      Adds a TypingLabel to the content table.
    • typing

      public TypingDialog typing​(@Null java.lang.String text, Font font, com.badlogic.gdx.graphics.Color color)
      Adds a TypingLabel to the content table.
    • typing

      public TypingDialog typing​(TypingLabel label)
      Adds the given TypingLabel to the content table.
      Parameters:
      label - a non-null TypingLabel
    • button

      public TypingDialog button​(@Null java.lang.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 TypingDialog 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 to result(Object) if this button is clicked. May be null.
    • button

      public TypingDialog button​(@Null java.lang.String text, @Null java.lang.Object object, com.badlogic.gdx.scenes.scene2d.ui.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 TypingDialog button​(com.badlogic.gdx.scenes.scene2d.ui.Button button)
      Adds the given button to the button table.
    • button

      public TypingDialog button​(com.badlogic.gdx.scenes.scene2d.ui.Button button, @Null java.lang.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 TypingDialog show​(com.badlogic.gdx.scenes.scene2d.Stage stage, @Null com.badlogic.gdx.scenes.scene2d.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 - May be null.
    • show

      public TypingDialog show​(com.badlogic.gdx.scenes.scene2d.Stage stage)
      Centers the dialog in the stage and calls show(Stage, Action) with a Actions.fadeIn(float, Interpolation) action.
    • hide

      public void hide​(@Null com.badlogic.gdx.scenes.scene2d.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.
    • setObject

      public void setObject​(com.badlogic.gdx.scenes.scene2d.Actor actor, @Null java.lang.Object object)
    • key

      public TypingDialog 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 unless cancel() is called.
      Parameters:
      object - The object specified when the button was added.
    • cancel

      public void cancel()