Class TypingLabel

java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.ui.Widget
com.github.tommyettinger.textra.TextraLabel
com.github.tommyettinger.textra.TypingLabel
All Implemented Interfaces:
com.badlogic.gdx.scenes.scene2d.utils.Layout

public class TypingLabel extends TextraLabel
An extension of TextraLabel that progressively shows the text as if it was being typed in real time, and allows the use of tokens in the format: {TOKEN=PARAMETER;ANOTHER_PARAMETER;MORE}. These tokens can add various effects to spans of text, such as the token WIND making text flutter and flap around, or BLINK making it flash an alternate color repeatedly. These work in addition to the tags permitted by TextraLabel, such as [light blue] for to change text color, or [_] to underline text. For compatibility with other systems that may already use curly braces, such as some I18N techniques, you can use [- instead of { and ] instead of } to use tokens without writing out curly braces.
This is meant to work with FWSkin or one of its subclasses, such as FreeTypistSkin, and isn't guaranteed to work with a regular Skin. FWSkin can load the same JSON files Skin uses, and it extends Skin.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final com.badlogic.gdx.utils.Array<Effect>
     
    protected boolean
     
    int
    The global glyph index (as used by setInWorkingLayout(int, long)) of the last glyph touched by the user.
    final com.badlogic.gdx.utils.FloatArray
    Contains two floats per glyph; even items are x offsets, odd items are y offsets.
    int
    The global glyph index (as used by setInWorkingLayout(int, long)) of the last glyph hovered or dragged over by the user (including a click and mouse movement without a click).
    final com.badlogic.gdx.utils.FloatArray
    Contains one float per glyph; each is a rotation in degrees to apply to that glyph (around its center).
    boolean
    If true, this label will allow clicking and dragging to select a range of text, if trackingInput is also true.
    int
    The inclusive end index for the selected text, if there is a selection.
    int
    The inclusive start index for the selected text, if there is a selection.
    final com.badlogic.gdx.utils.FloatArray
    Contains two floats per glyph, as size multipliers; even items apply to x, odd items apply to y.
    boolean
    If true, this will attempt to track which glyph the user's mouse or other pointer is over (see overIndex and lastTouchedIndex).
    protected final Layout
     

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

    align, font, layout, storedText, style, wrap
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a TypingLabel that uses the libGDX default font (lsans-15) and starts with no text.
    TypingLabel(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin)
    The skin should almost certainly be an FWSkin or one of its subclasses.
    TypingLabel(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, Font replacementFont)
    The skin should almost certainly be an FWSkin or one of its subclasses.
    TypingLabel(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName)
    The skin should almost certainly be an FWSkin or one of its subclasses.
    TypingLabel(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName, Font replacementFont)
    The skin should almost certainly be an FWSkin or one of its subclasses.
    TypingLabel(String text, Font font)
    Creates a TypingLabel with the given markup text and Font, without needing a skin.
    TypingLabel(String text, Font font, com.badlogic.gdx.graphics.Color color)
    Creates a TypingLabel with the given markup text, Font, and font color, without needing a skin.
    Creates a TypingLabel with the given markup text and style, without needing a skin.
    TypingLabel(String text, Styles.LabelStyle style, Font replacementFont)
    Creates a TypingLabel with the given markup text, style, and Font, without needing a skin.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    act(float delta)
     
    void
    Cancels calls to skipToTheEnd().
    void
    Removes all variables from this label.
    boolean
    If this label is selectable and there is a selected range of text, this copies that range of text to the clipboard and returns true; otherwise, it returns false.
    void
    draw(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha)
    If your font uses Font.DistanceFieldType.SDF or Font.DistanceFieldType.MSDF, then this has to do some extra work to use the appropriate shader.
    com.badlogic.gdx.graphics.Color
    Returns a Color instance with the color to be used on CLEARCOLOR tokens.
    Returns the default token being used in this label.
    Gets the ellipsis, which may be null, or may be a String that can be placed at the end of the text if its max lines are exceeded.
    long
     
    long
    getInLayout(Layout layout, int index)
     
     
    long
    getInWorkingLayout(int index)
     
    float
    getLineHeight(int index)
    Gets the height of the Line containing the glyph at the given index, in the working layout.
    getLineInLayout(Layout layout, int index)
     
    int
    The maximum number of Lines this label can display.
    Similar to Layout.toString(), but returns the original text with all the tokens unchanged.
    float
     
    float
     
    If this label is selectable and there is a selected range of text, this returns that range of text; otherwise, it returns the empty string.
    float
     
    Returns the TypingListener associated with this label.
    com.badlogic.gdx.utils.ObjectMap<String,String>
    Returns the ObjectMap with all the variable names and their respective replacement values that this label uses to handle {VAR=NAME} replacements.
    Returns the meant-for-internal-use-only Layout that is frequently changed as this label is displayed.
    boolean
    Returns whether this label's char progression has ended.
    void
    insertInLayout(Layout layout, int index, long newGlyph)
     
    void
    insertInLayout(Layout layout, int index, CharSequence text)
     
    boolean
    Returns whether this label is paused.
    boolean
    Returns true if and only if selectable is true and trackingInput is true; otherwise false.
    boolean
    Returns whether this label is currently skipping its typing progression all the way to the end.
    void
     
    int
    Gets the length in glyphs of the working layout (what is displayed).
    void
    Parses all tokens of this label.
    void
    Pauses this label's character progression.
    boolean
     
    void
    Removes a variable and its respective replacement value from this label's variable map.
    void
    Restarts this label with the original text and starts the char progression right away.
    void
    Restarts this label with the given text and starts the char progression right away.
    protected void
    Restores the original text with all tokens unchanged to this label.
    void
    Resumes this label's character progression.
    protected void
    Copies the content of getOriginalText() to the StringBuilder containing the original text with all tokens unchanged.
    void
    setDefaultToken(String defaultToken)
    Sets the default token being used in this label.
    void
    setEllipsis(String ellipsis)
    Sets the ellipsis text, which replaces the last few glyphs if non-null and the text added would exceed the getMaxLines() of this label's working layout.
    void
    setInLayout(Layout layout, int index, long newGlyph)
     
    void
    setIntermediateText(CharSequence text, boolean modifyOriginalText, boolean restart)
     
    void
    setInWorkingLayout(int index, long newGlyph)
     
    void
    setMaxLines(int maxLines)
    Sets the maximum number of Lines this Layout can display; this is always at least 1.
    setSelectable(boolean selectable)
    If given true, this makes the text of this label selectable and ensures trackingInput is true.
    void
    setSize(float width, float height)
     
    void
    setText(String newText)
    Modifies the text of this label.
    void
    setText(String newText, boolean modifyOriginalText)
    Sets the text of this label.
    void
    setText(String newText, boolean modifyOriginalText, boolean restart)
    Sets the text of this label.
    void
    setTextSpeed(float textSpeed)
     
    void
    Sets the TypingListener associated with this label, or null to remove the current one.
    void
    setVariable(String var, String value)
    Registers a variable and its respective replacement value to this label.
    void
    setVariables(com.badlogic.gdx.utils.ObjectMap<String,String> variableMap)
    Registers a set of variables and their respective replacement values to this label.
    void
    setVariables(Map<String,String> variableMap)
    Registers a set of variables and their respective replacement values to this label.
    Skips the char progression to the end, showing the entire label.
    skipToTheEnd(boolean ignoreEvents)
    Skips the char progression to the end, showing the entire label.
    skipToTheEnd(boolean ignoreEvents, boolean ignoreEffects)
    Skips the char progression to the end, showing the entire label.
    substring(int start, int end)
    Gets a String from the working layout of this label, made of only the char portions of the glyphs from start (inclusive) to end (exclusive).
     
    void
    triggerEvent(String event, boolean always)
    Triggers an event with the given String name.

    Methods inherited from class com.github.tommyettinger.textra.TextraLabel

    getAlignment, getFont, getGlyph, isWrap, setAlignment, setFont, setFont, setParent, setStage, setWrap, useIntegerPositions

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

    getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validate

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

    addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, 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, hit, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, scaleChanged, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, 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

    • workingLayout

      protected final Layout workingLayout
    • offsets

      public final com.badlogic.gdx.utils.FloatArray offsets
      Contains two floats per glyph; even items are x offsets, odd items are y offsets.
    • sizing

      public final com.badlogic.gdx.utils.FloatArray sizing
      Contains two floats per glyph, as size multipliers; even items apply to x, odd items apply to y.
    • rotations

      public final com.badlogic.gdx.utils.FloatArray rotations
      Contains one float per glyph; each is a rotation in degrees to apply to that glyph (around its center).
    • trackingInput

      public boolean trackingInput
      If true, this will attempt to track which glyph the user's mouse or other pointer is over (see overIndex and lastTouchedIndex).
    • selectable

      public boolean selectable
      If true, this label will allow clicking and dragging to select a range of text, if trackingInput is also true. This does not allow the text to be edited unless so implemented by another class. If text can be selected, then you can use getSelectedText() to get the selected String, or copySelectedText() to copy that text directly. To copy automatically, use a listener that checks TypingListener.event(String), and when the event String is "*SELECTED", that means a click-and-drag selected a range of text in this label, and you can do what you want with the selected text (such as call copySelectedText()).
    • lastTouchedIndex

      public int lastTouchedIndex
      The global glyph index (as used by setInWorkingLayout(int, long)) of the last glyph touched by the user. If nothing in this TypingLabel was touched during the last call to draw(Batch, float), then this will be either -1 (if the last touch was, roughly, before the first glyph) or -2 (if the last touch was after the last glyph). This only changes when a click, tap, or other touch was just issued.
    • overIndex

      public int overIndex
      The global glyph index (as used by setInWorkingLayout(int, long)) of the last glyph hovered or dragged over by the user (including a click and mouse movement without a click). If nothing in this TypingLabel was moved over during the last call to draw(Batch, float), then this will be -1 . This changes whenever the mouse or a pointer is over a glyph in this.
    • selectionStart

      public int selectionStart
      The inclusive start index for the selected text, if there is a selection. This should be -1 if there is no selection, or sometimes -2 if the selection went past the end of the text. This is essentially interchangeable with selectionEnd; as long as they are different, it doesn't matter which is higher or lower.
    • selectionEnd

      public int selectionEnd
      The inclusive end index for the selected text, if there is a selection. This should be -1 if there is no selection, or sometimes -2 if the selection went past the end of the text. This is essentially interchangeable with selectionStart; as long as they are different, it doesn't matter which is higher or lower.
    • dragging

      protected boolean dragging
    • activeEffects

      protected final com.badlogic.gdx.utils.Array<Effect> activeEffects
  • Constructor Details

    • TypingLabel

      public TypingLabel()
      Creates a TypingLabel that uses the libGDX default font (lsans-15) and starts with no text. The default font will not look very good when scaled, so this should usually stay its default font size.
    • TypingLabel

      public TypingLabel(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin)
      The skin should almost certainly be an FWSkin or one of its subclasses.
      Parameters:
      text - markup text that can contain square-bracket tags and curly-brace tokens
      skin - almost always an FWSkin or one of its subclasses; must have a Styles.LabelStyle or Label.LabelStyle registered as "default"
    • TypingLabel

      public TypingLabel(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, Font replacementFont)
      The skin should almost certainly be an FWSkin or one of its subclasses.
      Parameters:
      text - markup text that can contain square-bracket tags and curly-brace tokens
      skin - almost always an FWSkin or one of its subclasses; must have a Styles.LabelStyle or Label.LabelStyle registered as "default"
      replacementFont - will be used instead of the Font loaded from skin
    • TypingLabel

      public TypingLabel(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName)
      The skin should almost certainly be an FWSkin or one of its subclasses.
      Parameters:
      text - markup text that can contain square-bracket tags and curly-brace tokens
      skin - almost always an FWSkin or one of its subclasses; must have a Styles.LabelStyle or Label.LabelStyle registered with the given styleName
      styleName - the name of the Styles.LabelStyle to load from skin
    • TypingLabel

      public TypingLabel(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName, Font replacementFont)
      The skin should almost certainly be an FWSkin or one of its subclasses.
      Parameters:
      text - markup text that can contain square-bracket tags and curly-brace tokens
      skin - almost always an FWSkin or one of its subclasses; must have a Styles.LabelStyle or Label.LabelStyle registered with the given styleName
      styleName - the name of the Styles.LabelStyle to load from skin
      replacementFont - will be used instead of the Font loaded from skin
    • TypingLabel

      public TypingLabel(String text, Styles.LabelStyle style)
      Creates a TypingLabel with the given markup text and style, without needing a skin.
      Parameters:
      text - markup text that can contain square-bracket tags and curly-brace tokens
      style - a style from Styles and not from scene2d.ui; often made manually
    • TypingLabel

      public TypingLabel(String text, Styles.LabelStyle style, Font replacementFont)
      Creates a TypingLabel with the given markup text, style, and Font, without needing a skin.
      Parameters:
      text - markup text that can contain square-bracket tags and curly-brace tokens
      style - a style from Styles and not from scene2d.ui; often made manually
      replacementFont - will be used instead of the Font from the style
    • TypingLabel

      public TypingLabel(String text, Font font)
      Creates a TypingLabel with the given markup text and Font, without needing a skin.
      Parameters:
      text - markup text that can contain square-bracket tags and curly-brace tokens
      font - will be used for all text
    • TypingLabel

      public TypingLabel(String text, Font font, com.badlogic.gdx.graphics.Color color)
      Creates a TypingLabel with the given markup text, Font, and font color, without needing a skin.
      Parameters:
      text - markup text that can contain square-bracket tags and curly-brace tokens
      font - will be used for all text
      color - the default foreground color for text
  • Method Details

    • setText

      public void setText(String newText)
      Modifies the text of this label. If the char progression is already running, it's highly recommended to use restart(CharSequence) instead.
      Overrides:
      setText in class TextraLabel
      Parameters:
      newText - what to use as the new text (and original text) of this label
    • setText

      public void setText(String newText, boolean modifyOriginalText)
      Sets the text of this label. If the char progression is already running, it's highly recommended to use restart(CharSequence) instead. This overload allows specifying if the original text, which is used when parsing the tokens (with parseTokens()), should be changed to match the given text. If modifyOriginalText is true, this will preprocess the text, which should generally be run once per original text and no more.
      This overload calls setText(String, boolean, boolean) with restart set to false.
      Parameters:
      modifyOriginalText - Flag determining if the original text should be modified as well. If false, only the display text is changed while the original text is untouched. If true, then this runs Parser.preprocess(String) on the text, which should only generally be run once per original text.
      See Also:
    • setText

      public void setText(String newText, boolean modifyOriginalText, boolean restart)
      Sets the text of this label. If the char progression is already running, it's highly recommended to use restart(CharSequence) instead. This overload allows specifying if the original text, which is used when parsing the tokens (with parseTokens()), should be changed to match the given text. This will not ever call Parser.preprocess(String), which makes it different from setText(String, boolean). You can also specify whether the text animation should restart or not here.
      Parameters:
      modifyOriginalText - Flag determining if the original text should be modified as well. If false, only the display text is changed while the original text is untouched.
      restart - Whether this label should restart. Defaults to true.
      See Also:
    • getOriginalText

      public StringBuilder getOriginalText()
      Similar to Layout.toString(), but returns the original text with all the tokens unchanged.
    • saveOriginalText

      protected void saveOriginalText(CharSequence text)
      Copies the content of getOriginalText() to the StringBuilder containing the original text with all tokens unchanged.
    • restoreOriginalText

      protected void restoreOriginalText()
      Restores the original text with all tokens unchanged to this label. Make sure to call parseTokens() to parse the tokens again.
    • getTypingListener

      public TypingListener getTypingListener()
      Returns the TypingListener associated with this label. May be null.
    • setTypingListener

      public void setTypingListener(TypingListener listener)
      Sets the TypingListener associated with this label, or null to remove the current one.
    • getClearColor

      public com.badlogic.gdx.graphics.Color getClearColor()
      Returns a Color instance with the color to be used on CLEARCOLOR tokens. Modify this instance to change the token color. Default value is specified by TypingConfig.
      See Also:
    • getDefaultToken

      public String getDefaultToken()
      Returns the default token being used in this label. Defaults to empty string.
    • setDefaultToken

      public void setDefaultToken(String defaultToken)
      Sets the default token being used in this label. This token will be used before the label's text, and after each {RESET} call. Useful if you want a certain token to be active at all times without having to type it all the time.
    • parseTokens

      public void parseTokens()
      Parses all tokens of this label. Use this after setting the text and any variables that should be replaced.
    • skipToTheEnd

      public TypingLabel skipToTheEnd()
      Skips the char progression to the end, showing the entire label. Useful for when users don't want to wait for too long. Ignores all subsequent events by default. Doesn't change running effects. This calls act(float) with a delta of Float.MIN_VALUE, which allows the text to be skipped ahead without noticeably changing anything time-based.
      Overrides:
      skipToTheEnd in class TextraLabel
      Returns:
      this, for chaining
    • skipToTheEnd

      public TypingLabel skipToTheEnd(boolean ignoreEvents)
      Skips the char progression to the end, showing the entire label. Useful for when users don't want to wait for too long. This doesn't change running effects. This calls act(float) with a delta of Float.MIN_VALUE, which allows the text to be skipped ahead without noticeably changing anything time-based.
      Parameters:
      ignoreEvents - If true, skipped events won't be reported to the listener.
      Returns:
      this, for chaining
    • skipToTheEnd

      public TypingLabel skipToTheEnd(boolean ignoreEvents, boolean ignoreEffects)
      Skips the char progression to the end, showing the entire label. Useful for when users don't want to wait for too long. This calls act(float) with a delta of Float.MIN_VALUE, which allows the text to be skipped ahead without noticeably changing anything time-based.
      Parameters:
      ignoreEvents - If true, skipped events won't be reported to the listener.
      ignoreEffects - If true, all text effects will be instantly cancelled.
      Returns:
      this, for chaining
    • cancelSkipping

      public void cancelSkipping()
      Cancels calls to skipToTheEnd(). Useful if you need to restore the label's normal behavior at some event after skipping.
    • isSkipping

      public boolean isSkipping()
      Returns whether this label is currently skipping its typing progression all the way to the end. This is only true if skipToTheEnd is called.
    • isPaused

      public boolean isPaused()
      Returns whether this label is paused.
    • pause

      public void pause()
      Pauses this label's character progression.
    • resume

      public void resume()
      Resumes this label's character progression.
    • hasEnded

      public boolean hasEnded()
      Returns whether this label's char progression has ended.
    • restart

      public void restart()
      Restarts this label with the original text and starts the char progression right away. All tokens are automatically parsed.
    • restart

      public void restart(CharSequence newText)
      Restarts this label with the given text and starts the char progression right away. All tokens are automatically parsed. If you are reusing an existing TypingLabel and its size will change once it holds newText, you may need to call label.setSize(0, 0); before calling this. This does not change its size by itself, because restarting is also performed internally and changing the size internally could cause unexpected (read: very buggy) behavior for code using this library.
    • getVariables

      public com.badlogic.gdx.utils.ObjectMap<String,String> getVariables()
      Returns the ObjectMap with all the variable names and their respective replacement values that this label uses to handle {VAR=NAME} replacements. This returns the map directly.
    • setVariable

      public void setVariable(String var, String value)
      Registers a variable and its respective replacement value to this label.
      Parameters:
      var - the String name to use for a variable
      value - the String value to use as a replacement
    • removeVariable

      public void removeVariable(String var)
      Removes a variable and its respective replacement value from this label's variable map.
      Parameters:
      var - the String name of a variable to remove
    • setVariables

      public void setVariables(com.badlogic.gdx.utils.ObjectMap<String,String> variableMap)
      Registers a set of variables and their respective replacement values to this label.
      Parameters:
      variableMap - an ObjectMap of variable names to their replacement Strings
    • setVariables

      public void setVariables(Map<String,String> variableMap)
      Registers a set of variables and their respective replacement values to this label.
      Parameters:
      variableMap - a Map of variable names to their replacement Strings; null keys will be ignored silently
    • clearVariables

      public void clearVariables()
      Removes all variables from this label.
    • act

      public void act(float delta)
      Overrides:
      act in class com.badlogic.gdx.scenes.scene2d.Actor
    • remove

      public boolean remove()
      Overrides:
      remove in class TextraLabel
    • setSize

      public void setSize(float width, float height)
      Overrides:
      setSize in class TextraLabel
    • getPrefWidth

      public float getPrefWidth()
      Specified by:
      getPrefWidth in interface com.badlogic.gdx.scenes.scene2d.utils.Layout
      Overrides:
      getPrefWidth in class TextraLabel
    • getPrefHeight

      public float getPrefHeight()
      Specified by:
      getPrefHeight in interface com.badlogic.gdx.scenes.scene2d.utils.Layout
      Overrides:
      getPrefHeight in class TextraLabel
    • layout

      public void layout()
      Specified by:
      layout in interface com.badlogic.gdx.scenes.scene2d.utils.Layout
      Overrides:
      layout in class TextraLabel
    • draw

      public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha)
      If your font uses Font.DistanceFieldType.SDF or Font.DistanceFieldType.MSDF, then this has to do some extra work to use the appropriate shader. If Font.enableShader(Batch) was called before rendering a group of TypingLabels, then they will try to share one Batch; otherwise this will change the shader to render SDF or MSDF, then change it back at the end of each draw() call.
      Overrides:
      draw in class TextraLabel
      Parameters:
      batch - probably should be a SpriteBatch
      parentAlpha - the alpha of the parent container, or 1.0f if there is none
    • toString

      public String toString()
      Overrides:
      toString in class TextraLabel
    • getSelectedText

      public String getSelectedText()
      If this label is selectable and there is a selected range of text, this returns that range of text; otherwise, it returns the empty string.
      Returns:
      the currently selected text, or the empty string if none is or can be selected
    • copySelectedText

      public boolean copySelectedText()
      If this label is selectable and there is a selected range of text, this copies that range of text to the clipboard and returns true; otherwise, it returns false.
      Returns:
      true if text was copied, or false if the clipboard hasn't received any text
    • setIntermediateText

      public void setIntermediateText(CharSequence text, boolean modifyOriginalText, boolean restart)
    • getIntermediateText

      public StringBuilder getIntermediateText()
    • getInLayout

      public long getInLayout(Layout layout, int index)
    • getInWorkingLayout

      public long getInWorkingLayout(int index)
    • getWorkingLayout

      public Layout getWorkingLayout()
      Returns the meant-for-internal-use-only Layout that is frequently changed as this label is displayed. The working layout may be useful to have, even if treated as read-only, so it is exposed here. Still, be very careful with this method and the Layout it returns. The working layout is the one that gets shown, where layout() is used as the ideal text before wrapping or other requirements edit it.
      Returns:
      the mostly-internal working layout, which is the layout that gets displayed.
    • getMaxLines

      public int getMaxLines()
      The maximum number of Lines this label can display.
      Overrides:
      getMaxLines in class TextraLabel
      Returns:
      the maximum number of Line objects this label can display
    • setMaxLines

      public void setMaxLines(int maxLines)
      Sets the maximum number of Lines this Layout can display; this is always at least 1. For effectively unlimited lines, pass Integer.MAX_VALUE to this.
      Overrides:
      setMaxLines in class TextraLabel
      Parameters:
      maxLines - the limit for how many Line objects this Layout can display; always 1 or more
    • getEllipsis

      public String getEllipsis()
      Gets the ellipsis, which may be null, or may be a String that can be placed at the end of the text if its max lines are exceeded.
      Overrides:
      getEllipsis in class TextraLabel
      Returns:
      an ellipsis String or null
    • setEllipsis

      public void setEllipsis(String ellipsis)
      Sets the ellipsis text, which replaces the last few glyphs if non-null and the text added would exceed the getMaxLines() of this label's working layout. For the ellipsis to appear, this has to be called with a non-null String (often "...", or "…" if the font supports it), and setMaxLines(int) needs to have been called with a small enough number, such as 1.
      Overrides:
      setEllipsis in class TextraLabel
      Parameters:
      ellipsis - a String for a Layout to end with if its max lines are exceeded, or null to avoid such truncation
    • substring

      public String substring(int start, int end)
      Gets a String from the working layout of this label, made of only the char portions of the glyphs from start (inclusive) to end (exclusive). This can retrieve text from across multiple lines.
      Overrides:
      substring in class TextraLabel
      Parameters:
      start - inclusive start index
      end - exclusive end index
      Returns:
      a String made of only the char portions of the glyphs from start to end
    • getLineInLayout

      public Line getLineInLayout(Layout layout, int index)
    • getLineHeight

      public float getLineHeight(int index)
      Gets the height of the Line containing the glyph at the given index, in the working layout. If the index is out of bounds, this just returns Font.cellHeight.
      Overrides:
      getLineHeight in class TextraLabel
      Parameters:
      index - the 0-based index of the glyph to measure
      Returns:
      the height of the Line containing the specified glyph
    • getFromIntermediate

      public long getFromIntermediate(int index)
    • setInLayout

      public void setInLayout(Layout layout, int index, long newGlyph)
    • insertInLayout

      public void insertInLayout(Layout layout, int index, long newGlyph)
    • insertInLayout

      public void insertInLayout(Layout layout, int index, CharSequence text)
    • setInWorkingLayout

      public void setInWorkingLayout(int index, long newGlyph)
    • length

      public int length()
      Gets the length in glyphs of the working layout (what is displayed).
      Returns:
      the length in glyphs of the working layout (what is displayed)
    • triggerEvent

      public void triggerEvent(String event, boolean always)
      Triggers an event with the given String name. If always is true, this will trigger the event even if the typing animation has already ended. This requires a TypingListener to be set.
      Parameters:
      event - the event name to trigger
      always - if true, the event will be triggered even if the animation has finished.
    • isSelectable

      public boolean isSelectable()
      Returns true if and only if selectable is true and trackingInput is true; otherwise false.
      Returns:
      whether the text of this label is selectable
    • setSelectable

      public TypingLabel setSelectable(boolean selectable)
      If given true, this makes the text of this label selectable and ensures trackingInput is true. Otherwise, this makes the label not-selectable and doesn't change trackingInput. The application should usually be set to copy the selected text using copySelectedText() when the user expects it to be copied. Often, a TypingListener that checks for the event "*SELECTED" works.
      Parameters:
      selectable - true if the text of this label should be selectable
      Returns:
      this, for chaining
    • getTextSpeed

      public float getTextSpeed()
    • setTextSpeed

      public void setTextSpeed(float textSpeed)