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 Label that progressively shows the text as if it was being typed in real time, and allows the use of tokens in the following format: {TOKEN=PARAMETER}.
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected com.badlogic.gdx.utils.Array<Effect> activeEffects  
    protected boolean dragging  
    int lastTouchedIndex
    The global glyph index (as used by setInWorkingLayout(int, long)) of the last glyph touched by the user.
    com.badlogic.gdx.utils.FloatArray offsets
    Contains two floats per glyph; even items are x offsets, odd items are y offsets.
    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).
    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).
    boolean selectable
    If true, this label will allow clicking and dragging to select a range of text, if trackingInput is also true.
    int selectionEnd
    The inclusive end index for the selected text, if there is a selection.
    int selectionStart
    The inclusive start index for the selected text, if there is a selection.
    com.badlogic.gdx.utils.FloatArray sizing
    Contains two floats per glyph, as size multipliers; even items apply to x, odd items apply to y.
    protected com.badlogic.gdx.utils.Array<com.github.tommyettinger.textra.TokenEntry> tokenEntries  
    boolean trackingInput
    If true, this will attempt to track which glyph the user's mouse or other pointer is over (see overIndex and lastTouchedIndex).
    protected Layout workingLayout  

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

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

    Constructors
    Constructor Description
    TypingLabel()  
    TypingLabel​(java.lang.String text, com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle style)  
    TypingLabel​(java.lang.String text, com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle style, Font replacementFont)  
    TypingLabel​(java.lang.String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin)  
    TypingLabel​(java.lang.String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, Font replacementFont)  
    TypingLabel​(java.lang.String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, java.lang.String styleName)  
    TypingLabel​(java.lang.String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, java.lang.String styleName, Font replacementFont)  
    TypingLabel​(java.lang.String text, Font font)  
    TypingLabel​(java.lang.String text, Font font, com.badlogic.gdx.graphics.Color color)  
  • Method Summary

    Modifier and Type Method Description
    void act​(float delta)  
    void cancelSkipping()
    Cancels calls to skipToTheEnd().
    void clearVariables()
    Removes all variables from this label.
    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.
    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 getClearColor()
    Returns a Color instance with the color to be used on CLEARCOLOR tokens.
    java.lang.String getDefaultToken()
    Returns the default token being used in this label.
    java.lang.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.
    long getFromIntermediate​(int index)  
    long getInLayout​(Layout layout, int index)  
    java.lang.StringBuilder getIntermediateText()  
    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.
    Line getLineInLayout​(Layout layout, int index)  
    int getMaxLines()
    The maximum number of Lines this label can display.
    java.lang.StringBuilder getOriginalText()
    Similar to Layout.toString(), but returns the original text with all the tokens unchanged.
    float getPrefHeight()  
    float getPrefWidth()  
    java.lang.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.
    TypingListener getTypingListener()
    Returns the TypingListener associated with this label.
    com.badlogic.gdx.utils.ObjectMap<java.lang.String,​java.lang.String> getVariables()
    Returns an ObjectMap with all the variable names and their respective replacement values.
    Layout getWorkingLayout()
    Returns the meant-for-internal-use-only Layout that is frequently changed as this label is displayed.
    boolean hasEnded()
    Returns whether this label's char progression has ended.
    void insertInLayout​(Layout layout, int index, long newGlyph)  
    void insertInLayout​(Layout layout, int index, java.lang.CharSequence text)  
    boolean isPaused()
    Returns whether this label is paused.
    boolean isSelectable()
    Returns true if and only if selectable is true and trackingInput is true; otherwise false.
    boolean isSkipping()
    Returns whether this label is currently skipping its typing progression all the way to the end.
    void layout()  
    int length()
    Gets the length in glyphs of the working layout (what is displayed).
    void parseTokens()
    Parses all tokens of this label.
    void pause()
    Pauses this label's character progression.
    boolean remove()  
    void restart()
    Restarts this label with the original text and starts the char progression right away.
    void restart​(java.lang.String newText)
    Restarts this label with the given text and starts the char progression right away.
    protected void restoreOriginalText()
    Restores the original text with all tokens unchanged to this label.
    void resume()
    Resumes this label's character progression.
    protected void saveOriginalText​(java.lang.CharSequence text)
    Copies the content of getOriginalText() to the StringBuilder containing the original text with all tokens unchanged.
    void setDefaultToken​(java.lang.String defaultToken)
    Sets the default token being used in this label.
    void setEllipsis​(java.lang.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​(java.lang.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.
    TypingLabel 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​(java.lang.String newText)
    Modifies the text of this label.
    void setText​(java.lang.String newText, boolean modifyOriginalText)
    Sets the text of this label.
    void setText​(java.lang.String newText, boolean modifyOriginalText, boolean restart)
    Sets the text of this label.
    void setTypingListener​(TypingListener listener)
    Sets the TypingListener associated with this label, or null to remove the current one.
    void setVariable​(java.lang.String var, java.lang.String value)
    Registers a variable and its respective replacement value to this label.
    void setVariables​(com.badlogic.gdx.utils.ObjectMap<java.lang.String,​java.lang.String> variableMap)
    Registers a set of variables and their respective replacement values to this label.
    void setVariables​(java.util.Map<java.lang.String,​java.lang.String> variableMap)
    Registers a set of variables and their respective replacement values to this label.
    void skipToTheEnd()
    Skips the char progression to the end, showing the entire label.
    void skipToTheEnd​(boolean ignoreEvents)
    Skips the char progression to the end, showing the entire label.
    void skipToTheEnd​(boolean ignoreEvents, boolean ignoreEffects)
    Skips the char progression to the end, showing the entire label.
    java.lang.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).
    java.lang.String toString()  
    void triggerEvent​(java.lang.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

    • tokenEntries

      protected final com.badlogic.gdx.utils.Array<com.github.tommyettinger.textra.TokenEntry> tokenEntries
    • 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()
    • TypingLabel

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

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

      public TypingLabel​(java.lang.String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, java.lang.String styleName)
    • TypingLabel

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

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

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

      public TypingLabel​(java.lang.String text, Font font)
    • TypingLabel

      public TypingLabel​(java.lang.String text, Font font, com.badlogic.gdx.graphics.Color color)
  • Method Details

    • setText

      public void setText​(java.lang.String newText)
      Modifies the text of this label. If the char progression is already running, it's highly recommended to use restart(String) 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​(java.lang.String newText, boolean modifyOriginalText)
      Sets the text of this label. If the char progression is already running, it's highly recommended to use restart(String) 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(CharSequence) on the text, which should only generally be run once per original text.
      See Also:
      restart(String)
    • setText

      public void setText​(java.lang.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(String) 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(CharSequence), 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:
      restart(String)
    • getOriginalText

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

      protected void saveOriginalText​(java.lang.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:
      TypingConfig.DEFAULT_CLEAR_COLOR
    • getDefaultToken

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

      public void setDefaultToken​(java.lang.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 void 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. 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
    • skipToTheEnd

      public void 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 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.
    • skipToTheEnd

      public void 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.
    • 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​(java.lang.String 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<java.lang.String,​java.lang.String> getVariables()
      Returns an ObjectMap with all the variable names and their respective replacement values.
    • setVariable

      public void setVariable​(java.lang.String var, java.lang.String value)
      Registers a variable and its respective replacement value to this label.
    • setVariables

      public void setVariables​(com.badlogic.gdx.utils.ObjectMap<java.lang.String,​java.lang.String> variableMap)
      Registers a set of variables and their respective replacement values to this label.
    • setVariables

      public void setVariables​(java.util.Map<java.lang.String,​java.lang.String> variableMap)
      Registers a set of variables and their respective replacement values to this label.
    • 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 java.lang.String toString()
      Overrides:
      toString in class TextraLabel
    • getSelectedText

      public java.lang.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​(java.lang.CharSequence text, boolean modifyOriginalText, boolean restart)
    • getIntermediateText

      public java.lang.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 java.lang.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​(java.lang.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 java.lang.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, java.lang.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​(java.lang.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