Package com.github.tommyettinger.textra
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
An extension of
This is meant to work with
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
FieldsModifier and TypeFieldDescriptionprotected final com.badlogic.gdx.utils.Array<Effect>
protected boolean
int
The global glyph index (as used bysetInWorkingLayout(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 bysetInWorkingLayout(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, iftrackingInput
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 (seeoverIndex
andlastTouchedIndex
).protected final Layout
Fields inherited from class com.github.tommyettinger.textra.TextraLabel
align, font, layout, storedText, style, wrap
-
Constructor Summary
ConstructorsConstructorDescriptionCreates 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 anFWSkin
or one of its subclasses.TypingLabel
(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, Font replacementFont) The skin should almost certainly be anFWSkin
or one of its subclasses.TypingLabel
(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName) The skin should almost certainly be anFWSkin
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 anFWSkin
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.TypingLabel
(String text, Styles.LabelStyle style) 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 TypeMethodDescriptionvoid
act
(float delta) void
Cancels calls toskipToTheEnd()
.void
Removes all variables from this label.boolean
If this label isselectable
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 usesFont.DistanceFieldType.SDF
orFont.DistanceFieldType.MSDF
, then this has to do some extra work to use the appropriate shader.com.badlogic.gdx.graphics.Color
Returns aColor
instance with the color to be used onCLEARCOLOR
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
getFromIntermediate
(int index) 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 ofLine
s this label can display.Similar toLayout.toString()
, but returns the original text with all the tokens unchanged.float
float
If this label isselectable
and there is a selected range of text, this returns that range of text; otherwise, it returns the empty string.float
Returns theTypingListener
associated with this label.Returns theObjectMap
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
hasEnded()
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
isPaused()
Returns whether this label is paused.boolean
Returns true if and only ifselectable
is true andtrackingInput
is true; otherwise false.boolean
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
Parses all tokens of this label.void
pause()
Pauses this label's character progression.boolean
remove()
void
removeVariable
(String var) Removes a variable and its respective replacement value from this label's variable map.void
restart()
Restarts this label with the original text and starts the char progression right away.void
restart
(CharSequence newText) 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
resume()
Resumes this label's character progression.protected void
saveOriginalText
(CharSequence text) Copies the content ofgetOriginalText()
to theStringBuilder
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 thegetMaxLines()
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 ofLine
s this Layout can display; this is always at least 1.setSelectable
(boolean selectable) void
setSize
(float width, float height) void
Modifies the text of this label.void
Sets the text of this label.void
Sets the text of this label.void
setTextSpeed
(float textSpeed) void
setTypingListener
(TypingListener listener) Sets theTypingListener
associated with this label, ornull
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).toString()
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
-
Field Details
-
workingLayout
-
offsets
public final com.badlogic.gdx.utils.FloatArray offsetsContains two floats per glyph; even items are x offsets, odd items are y offsets. -
sizing
public final com.badlogic.gdx.utils.FloatArray sizingContains 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 rotationsContains one float per glyph; each is a rotation in degrees to apply to that glyph (around its center). -
trackingInput
public boolean trackingInputIf true, this will attempt to track which glyph the user's mouse or other pointer is over (seeoverIndex
andlastTouchedIndex
). -
selectable
public boolean selectableIf true, this label will allow clicking and dragging to select a range of text, iftrackingInput
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 usegetSelectedText()
to get the selected String, orcopySelectedText()
to copy that text directly. To copy automatically, use a listener that checksTypingListener.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 callcopySelectedText()
). -
lastTouchedIndex
public int lastTouchedIndexThe global glyph index (as used bysetInWorkingLayout(int, long)
) of the last glyph touched by the user. If nothing in this TypingLabel was touched during the last call todraw(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 overIndexThe global glyph index (as used bysetInWorkingLayout(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 todraw(Batch, float)
, then this will be -1 . This changes whenever the mouse or a pointer is over a glyph in this. -
selectionStart
public int selectionStartThe 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 withselectionEnd
; as long as they are different, it doesn't matter which is higher or lower. -
selectionEnd
public int selectionEndThe 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 withselectionStart
; as long as they are different, it doesn't matter which is higher or lower. -
dragging
protected boolean dragging -
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
The skin should almost certainly be anFWSkin
or one of its subclasses.- Parameters:
text
- markup text that can contain square-bracket tags and curly-brace tokensskin
- almost always anFWSkin
or one of its subclasses; must have aStyles.LabelStyle
orLabel.LabelStyle
registered as "default"
-
TypingLabel
The skin should almost certainly be anFWSkin
or one of its subclasses.- Parameters:
text
- markup text that can contain square-bracket tags and curly-brace tokensskin
- almost always anFWSkin
or one of its subclasses; must have aStyles.LabelStyle
orLabel.LabelStyle
registered as "default"replacementFont
- will be used instead of the Font loaded from skin
-
TypingLabel
The skin should almost certainly be anFWSkin
or one of its subclasses.- Parameters:
text
- markup text that can contain square-bracket tags and curly-brace tokensskin
- almost always anFWSkin
or one of its subclasses; must have aStyles.LabelStyle
orLabel.LabelStyle
registered with the given styleNamestyleName
- the name of theStyles.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 anFWSkin
or one of its subclasses.- Parameters:
text
- markup text that can contain square-bracket tags and curly-brace tokensskin
- almost always anFWSkin
or one of its subclasses; must have aStyles.LabelStyle
orLabel.LabelStyle
registered with the given styleNamestyleName
- the name of theStyles.LabelStyle
to load from skinreplacementFont
- will be used instead of the Font loaded from skin
-
TypingLabel
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 tokensstyle
- a style fromStyles
and not from scene2d.ui; often made manually
-
TypingLabel
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 tokensstyle
- a style fromStyles
and not from scene2d.ui; often made manuallyreplacementFont
- will be used instead of the Font from the style
-
TypingLabel
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 tokensfont
- will be used for all text
-
TypingLabel
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 tokensfont
- will be used for all textcolor
- the default foreground color for text
-
-
Method Details
-
setText
Modifies the text of this label. If the char progression is already running, it's highly recommended to userestart(CharSequence)
instead.- Overrides:
setText
in classTextraLabel
- Parameters:
newText
- what to use as the new text (and original text) of this label
-
setText
Sets the text of this label. If the char progression is already running, it's highly recommended to userestart(CharSequence)
instead. This overload allows specifying if the original text, which is used when parsing the tokens (withparseTokens()
), should be changed to match the given text. IfmodifyOriginalText
is true, this willpreprocess
the text, which should generally be run once per original text and no more.
This overload callssetText(String, boolean, boolean)
withrestart
set to false.- Parameters:
modifyOriginalText
- Flag determining if the original text should be modified as well. Iffalse
, only the display text is changed while the original text is untouched. Iftrue
, then this runsParser.preprocess(String)
on the text, which should only generally be run once per original text.- See Also:
-
setText
Sets the text of this label. If the char progression is already running, it's highly recommended to userestart(CharSequence)
instead. This overload allows specifying if the original text, which is used when parsing the tokens (withparseTokens()
), should be changed to match the given text. This will not ever callParser.preprocess(String)
, which makes it different fromsetText(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. Iffalse
, only the display text is changed while the original text is untouched.restart
- Whether this label should restart. Defaults to true.- See Also:
-
getOriginalText
Similar toLayout.toString()
, but returns the original text with all the tokens unchanged. -
saveOriginalText
Copies the content ofgetOriginalText()
to theStringBuilder
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 callparseTokens()
to parse the tokens again. -
getTypingListener
Returns theTypingListener
associated with this label. May benull
. -
setTypingListener
Sets theTypingListener
associated with this label, ornull
to remove the current one. -
getClearColor
public com.badlogic.gdx.graphics.Color getClearColor()Returns aColor
instance with the color to be used onCLEARCOLOR
tokens. Modify this instance to change the token color. Default value is specified byTypingConfig
.- See Also:
-
getDefaultToken
Returns the default token being used in this label. Defaults to empty string. -
setDefaultToken
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
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 callsact(float)
with a delta ofFloat.MIN_VALUE
, which allows the text to be skipped ahead without noticeably changing anything time-based.- Overrides:
skipToTheEnd
in classTextraLabel
- Returns:
- this, for chaining
-
skipToTheEnd
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 callsact(float)
with a delta ofFloat.MIN_VALUE
, which allows the text to be skipped ahead without noticeably changing anything time-based.- Parameters:
ignoreEvents
- Iftrue
, skipped events won't be reported to the listener.- Returns:
- this, for chaining
-
skipToTheEnd
Skips the char progression to the end, showing the entire label. Useful for when users don't want to wait for too long. This callsact(float)
with a delta ofFloat.MIN_VALUE
, which allows the text to be skipped ahead without noticeably changing anything time-based.- Parameters:
ignoreEvents
- Iftrue
, skipped events won't be reported to the listener.ignoreEffects
- Iftrue
, all text effects will be instantly cancelled.- Returns:
- this, for chaining
-
cancelSkipping
public void cancelSkipping()Cancels calls toskipToTheEnd()
. 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
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 holdsnewText
, you may need to calllabel.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
Returns theObjectMap
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
Registers a variable and its respective replacement value to this label.- Parameters:
var
- the String name to use for a variablevalue
- the String value to use as a replacement
-
removeVariable
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
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
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 classcom.badlogic.gdx.scenes.scene2d.Actor
-
remove
public boolean remove()- Overrides:
remove
in classTextraLabel
-
setSize
public void setSize(float width, float height) - Overrides:
setSize
in classTextraLabel
-
getPrefWidth
public float getPrefWidth()- Specified by:
getPrefWidth
in interfacecom.badlogic.gdx.scenes.scene2d.utils.Layout
- Overrides:
getPrefWidth
in classTextraLabel
-
getPrefHeight
public float getPrefHeight()- Specified by:
getPrefHeight
in interfacecom.badlogic.gdx.scenes.scene2d.utils.Layout
- Overrides:
getPrefHeight
in classTextraLabel
-
layout
public void layout()- Specified by:
layout
in interfacecom.badlogic.gdx.scenes.scene2d.utils.Layout
- Overrides:
layout
in classTextraLabel
-
draw
public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha) If your font usesFont.DistanceFieldType.SDF
orFont.DistanceFieldType.MSDF
, then this has to do some extra work to use the appropriate shader. IfFont.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 classTextraLabel
- Parameters:
batch
- probably should be a SpriteBatchparentAlpha
- the alpha of the parent container, or 1.0f if there is none
-
toString
- Overrides:
toString
in classTextraLabel
-
getSelectedText
If this label isselectable
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 isselectable
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
-
getIntermediateText
-
getInLayout
-
getInWorkingLayout
public long getInWorkingLayout(int index) -
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, wherelayout()
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 ofLine
s this label can display.- Overrides:
getMaxLines
in classTextraLabel
- Returns:
- the maximum number of
Line
objects this label can display
-
setMaxLines
public void setMaxLines(int maxLines) Sets the maximum number ofLine
s this Layout can display; this is always at least 1. For effectively unlimited lines, passInteger.MAX_VALUE
to this.- Overrides:
setMaxLines
in classTextraLabel
- Parameters:
maxLines
- the limit for how many Line objects this Layout can display; always 1 or more
-
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 classTextraLabel
- Returns:
- an ellipsis String or null
-
setEllipsis
Sets the ellipsis text, which replaces the last few glyphs if non-null and the text added would exceed thegetMaxLines()
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), andsetMaxLines(int)
needs to have been called with a small enough number, such as 1.- Overrides:
setEllipsis
in classTextraLabel
- Parameters:
ellipsis
- a String for a Layout to end with if its max lines are exceeded, or null to avoid such truncation
-
substring
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 classTextraLabel
- Parameters:
start
- inclusive start indexend
- exclusive end index- Returns:
- a String made of only the char portions of the glyphs from start to end
-
getLineInLayout
-
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 returnsFont.cellHeight
.- Overrides:
getLineHeight
in classTextraLabel
- 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
-
insertInLayout
-
insertInLayout
-
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
Triggers an event with the given String name. Ifalways
is true, this will trigger the event even if the typing animation has already ended. This requires aTypingListener
to be set.- Parameters:
event
- the event name to triggeralways
- if true, the event will be triggered even if the animation has finished.
-
isSelectable
public boolean isSelectable()Returns true if and only ifselectable
is true andtrackingInput
is true; otherwise false.- Returns:
- whether the text of this label is selectable
-
setSelectable
If giventrue
, this makes the text of this labelselectable
and ensurestrackingInput
is true. Otherwise, this makes the label not-selectable and doesn't changetrackingInput
. The application should usually be set to copy the selected text usingcopySelectedText()
when the user expects it to be copied. Often, aTypingListener
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)
-