Class TextraArea

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.Container<com.badlogic.gdx.scenes.scene2d.ui.ScrollPane>
com.github.tommyettinger.textra.TextraArea
All Implemented Interfaces:
com.badlogic.gdx.scenes.scene2d.utils.Cullable, com.badlogic.gdx.scenes.scene2d.utils.Layout

public class TextraArea extends com.badlogic.gdx.scenes.scene2d.ui.Container<com.badlogic.gdx.scenes.scene2d.ui.ScrollPane>
A multiple-line TextraField using a Font. This allows SDF and MSDF fonts to be used for text entry, as well as for emoji to be pasted into input fields. Entering emoji with an OS emoji picker doesn't work due to a limitation of libGDX on desktop platforms, though emoji can be copied from or pasted into a TextraArea. This creates a scroll bar if there are too many lines to be seen, and resizes the input area to account for the scroll bar. Unlike a scene2d.ui TextArea, this needs a ScrollPane.ScrollPaneStyle to provide a visual for the scroll bar.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
    A multiple-line TextraField using a Font; this is the inner multi-line text entry field that gets scrolled through by the parent class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The actual widget that handles text entry; the rest of TextraArea only handles the scrolling through this widget.

    Fields inherited from class com.badlogic.gdx.scenes.scene2d.Actor

    POOLS
  • Constructor Summary

    Constructors
    Constructor
    Description
    TextraArea(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin)
    Creates a TextraArea with the given initial text and skin to get styles from.
    TextraArea(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, Font replacementFont)
    Creates a TextraArea with the given initial text, skin to get styles from, and replacementFont.
    TextraArea(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName, String paneStyleName)
    Creates a TextraArea with the given initial text, skin to get styles from, and names of styles.
    TextraArea(String text, Styles.TextFieldStyle style, com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.ScrollPaneStyle paneStyle)
    Creates an InnerTextraArea with the given initial text and styles.
    TextraArea(String text, Styles.TextFieldStyle style, com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.ScrollPaneStyle paneStyle, Font replacementFont)
    Creates a TextraArea with the given initial text, styles, and replacementFont.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    void
    setFont(Font font)
     
    protected void
     

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Container

    addActor, addActorAfter, addActorAt, addActorBefore, align, background, bottom, center, clip, clip, draw, drawBackground, drawDebug, fill, fill, fill, fill, fillX, fillY, getActor, getAlign, getBackground, getClip, getFillX, getFillY, getMaxHeight, getMaxHeightValue, getMaxWidth, getMaxWidthValue, getMinHeight, getMinHeightValue, getMinWidth, getPadBottom, getPadBottomValue, getPadLeft, getPadLeftValue, getPadRight, getPadRightValue, getPadTop, getPadTopValue, getPadX, getPadY, getPrefHeight, getPrefHeightValue, getPrefWidth, getPrefWidthValue, height, height, hit, layout, left, maxHeight, maxHeight, maxSize, maxSize, maxSize, maxSize, maxWidth, maxWidth, minHeight, minHeight, minSize, minSize, minSize, minSize, minWidth, minWidth, pad, pad, pad, pad, padBottom, padBottom, padLeft, padLeft, padRight, padRight, padTop, padTop, prefHeight, prefHeight, prefSize, prefSize, prefSize, prefSize, prefWidth, prefWidth, removeActor, removeActor, removeActorAt, right, setActor, setBackground, setBackground, setClip, setCullingArea, setRound, size, size, size, size, top, width, width

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup

    childrenChanged, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, validate

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group

    act, applyTransform, applyTransform, clear, clear, clearChildren, clearChildren, computeTransform, debugAll, drawChildren, drawDebugChildren, findActor, getChild, getChildren, getCullingArea, hasChildren, isTransform, localToDescendantCoordinates, resetTransform, resetTransform, setDebug, setStage, setTransform, swapActor, swapActor, toString

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor

    addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebugBounds, 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, setDebug, 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

    • inner

      public final TextraArea.InnerTextraArea inner
      The actual widget that handles text entry; the rest of TextraArea only handles the scrolling through this widget.
  • Constructor Details

    • TextraArea

      public TextraArea(@Null String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin)
      Creates a TextraArea with the given initial text and skin to get styles from. Unlike TextArea in scene2d.ui, this shows a scrollbar, so it needs a ScrollPane.ScrollPaneStyle given to style that scrollbar.
      This gets a TextFieldStyle and a ScrollPaneStyle from skin. If a scene2d.ui TextFieldStyle is defined and an FWSkin (or subclass) reads in the Skin JSON file, this will be able to load the right TextFieldStyle from Styles in this package.
      Parameters:
      text - the initial text to hold in the TextraArea
      skin - a scene2d.ui Skin, typically an FWSkin or one of its subclasses
    • TextraArea

      public TextraArea(@Null String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, Font replacementFont)
      Creates a TextraArea with the given initial text, skin to get styles from, and replacementFont. Unlike TextArea in scene2d.ui, this shows a scrollbar, so it needs a ScrollPane.ScrollPaneStyle given to style that scrollbar.
      Sets Font.enableSquareBrackets and Font.omitCurlyBraces each to false on replacementFont. This does not copy replacementFont; you can reuse an existing Font with those two fields set to false. Note that if you reuse a Font that is used in conjunction with markup, the modifications this makes to that Font will make that markup remain unparsed. You will typically want a different Font for your replacementFont used in TextraArea(s) than your Font(s) used elsewhere.
      This gets a TextFieldStyle and a ScrollPaneStyle from skin. If a scene2d.ui TextFieldStyle is defined and an FWSkin (or subclass) reads in the Skin JSON file, this will be able to load the right TextFieldStyle from Styles in this package.
      Parameters:
      text - the initial text to hold in the TextraArea
      skin - a scene2d.ui Skin, typically an FWSkin or one of its subclasses
      replacementFont - a Font that will be modified in-place to diable brace/bracket markup parsing
    • TextraArea

      public TextraArea(@Null String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName, String paneStyleName)
      Creates a TextraArea with the given initial text, skin to get styles from, and names of styles. Unlike TextArea in scene2d.ui, this shows a scrollbar, so it needs a ScrollPane.ScrollPaneStyle given to style that scrollbar.
      This gets a TextFieldStyle and a ScrollPaneStyle from skin. If a scene2d.ui TextFieldStyle is defined and an FWSkin (or subclass) reads in the Skin JSON file, this will be able to load the right TextFieldStyle from Styles in this package.
      Parameters:
      text - the initial text to hold in the TextraArea
      skin - a scene2d.ui Skin, typically an FWSkin or one of its subclasses
      styleName - the name of a TextFieldStyle in skin
      paneStyleName - the name of a ScrollPaneStyle in skin
    • TextraArea

      public TextraArea(String text, Styles.TextFieldStyle style, com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.ScrollPaneStyle paneStyle)
      Creates an InnerTextraArea with the given initial text and styles. Unlike TextArea in scene2d.ui, this shows a scrollbar, so it needs a ScrollPane.ScrollPaneStyle given to style that scrollbar.
      This assumes the Styles.TextFieldStyle.font has not been modified; the constructor for TextFieldStyle copies any Font given to it so this can set Font.enableSquareBrackets and Font.omitCurlyBraces each to false on its copy without affecting other widget styles.
      Parameters:
      text - the initial text to hold in the TextraArea
      style - a TextFieldStyle from Styles
      paneStyle - a scene2d.ui ScrollPaneStyle
    • TextraArea

      public TextraArea(String text, Styles.TextFieldStyle style, com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.ScrollPaneStyle paneStyle, Font replacementFont)
      Creates a TextraArea with the given initial text, styles, and replacementFont. Unlike TextArea in scene2d.ui, this shows a scrollbar, so it needs a ScrollPane.ScrollPaneStyle given to style that scrollbar.
      Sets Font.enableSquareBrackets and Font.omitCurlyBraces each to false on replacementFont. This does not copy replacementFont; you can reuse an existing Font with those two fields set to false. Note that if you reuse a Font that is used in conjunction with markup, the modifications this makes to that Font will make that markup remain unparsed. You will typically want a different Font for your replacementFont used in TextraArea(s) than your Font(s) used elsewhere.
      Parameters:
      text - the initial text to hold in the TextraArea
      style - a TextFieldStyle from Styles
      paneStyle - a ScrollPane.ScrollPaneStyle from scene2d.ui
      replacementFont - a Font that will be modified in-place to diable brace/bracket markup parsing
  • Method Details

    • getFont

      public Font getFont()
    • setFont

      public void setFont(Font font)
    • sizeChanged

      protected void sizeChanged()
      Overrides:
      sizeChanged in class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup