Package com.github.tommyettinger.textra
Class TextraArea
java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.Group
com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
com.badlogic.gdx.scenes.scene2d.ui.Container<com.badlogic.gdx.scenes.scene2d.ui.ScrollPane>
com.github.tommyettinger.textra.TextraArea
- All Implemented Interfaces:
com.badlogic.gdx.scenes.scene2d.utils.Cullable,com.badlogic.gdx.scenes.scene2d.utils.Layout
public class TextraArea
extends com.badlogic.gdx.scenes.scene2d.ui.Container<com.badlogic.gdx.scenes.scene2d.ui.ScrollPane>
A multiple-line
TextraField using a Font. This allows SDF and MSDF fonts to be used for text entry,
as well as for emoji to be pasted into input fields. Entering emoji with an OS emoji picker doesn't work due to a
limitation of libGDX on desktop platforms, though emoji can be copied from or pasted into a TextraArea. This creates
a scroll bar if there are too many lines to be seen, and resizes the input area to account for the scroll bar. Unlike
a scene2d.ui TextArea, this needs a ScrollPane.ScrollPaneStyle to provide a visual for the scroll bar.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassA multiple-lineTextraFieldusing aFont; this is the inner multi-line text entry field that gets scrolled through by the parent class. -
Field Summary
FieldsModifier and TypeFieldDescriptionThe actual widget that handles text entry; the rest of TextraArea only handles the scrolling through this widget.Fields inherited from class com.badlogic.gdx.scenes.scene2d.Actor
POOLS -
Constructor Summary
ConstructorsConstructorDescriptionTextraArea(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin) Creates a TextraArea with the given initial text and skin to get styles from.TextraArea(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, Font replacementFont) Creates a TextraArea with the given initial text, skin to get styles from, and replacementFont.TextraArea(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName, String paneStyleName) Creates a TextraArea with the given initial text, skin to get styles from, and names of styles.TextraArea(String text, Styles.TextFieldStyle style, com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.ScrollPaneStyle paneStyle) Creates an InnerTextraArea with the given initial text and styles.TextraArea(String text, Styles.TextFieldStyle style, com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.ScrollPaneStyle paneStyle, Font replacementFont) Creates a TextraArea with the given initial text, styles, and replacementFont. -
Method Summary
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Container
addActor, addActorAfter, addActorAt, addActorBefore, align, background, bottom, center, clip, clip, draw, drawBackground, drawDebug, fill, fill, fill, fill, fillX, fillY, getActor, getAlign, getBackground, getClip, getFillX, getFillY, getMaxHeight, getMaxHeightValue, getMaxWidth, getMaxWidthValue, getMinHeight, getMinHeightValue, getMinWidth, getPadBottom, getPadBottomValue, getPadLeft, getPadLeftValue, getPadRight, getPadRightValue, getPadTop, getPadTopValue, getPadX, getPadY, getPrefHeight, getPrefHeightValue, getPrefWidth, getPrefWidthValue, height, height, hit, layout, left, maxHeight, maxHeight, maxSize, maxSize, maxSize, maxSize, maxWidth, maxWidth, minHeight, minHeight, minSize, minSize, minSize, minSize, minWidth, minWidth, pad, pad, pad, pad, padBottom, padBottom, padLeft, padLeft, padRight, padRight, padTop, padTop, prefHeight, prefHeight, prefSize, prefSize, prefSize, prefSize, prefWidth, prefWidth, removeActor, removeActor, removeActorAt, right, setActor, setBackground, setBackground, setClip, setCullingArea, setRound, size, size, size, size, top, width, widthMethods inherited from class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
childrenChanged, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, validateMethods inherited from class com.badlogic.gdx.scenes.scene2d.Group
act, applyTransform, applyTransform, clear, clear, clearChildren, clearChildren, computeTransform, debugAll, drawChildren, drawDebugChildren, findActor, getChild, getChildren, getCullingArea, hasChildren, isTransform, localToDescendantCoordinates, resetTransform, resetTransform, setDebug, setStage, setTransform, swapActor, swapActor, toStringMethods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebugBounds, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, scaleChanged, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront
-
Field Details
-
inner
The actual widget that handles text entry; the rest of TextraArea only handles the scrolling through this widget.
-
-
Constructor Details
-
TextraArea
Creates a TextraArea with the given initial text and skin to get styles from. UnlikeTextAreain scene2d.ui, this shows a scrollbar, so it needs aScrollPane.ScrollPaneStylegiven to style that scrollbar.
This gets a TextFieldStyle and a ScrollPaneStyle from skin. If a scene2d.ui TextFieldStyle is defined and an FWSkin (or subclass) reads in the Skin JSON file, this will be able to load the right TextFieldStyle from Styles in this package.- Parameters:
text- the initial text to hold in the TextraAreaskin- a scene2d.ui Skin, typically anFWSkinor one of its subclasses
-
TextraArea
public TextraArea(@Null String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, Font replacementFont) Creates a TextraArea with the given initial text, skin to get styles from, and replacementFont. UnlikeTextAreain scene2d.ui, this shows a scrollbar, so it needs aScrollPane.ScrollPaneStylegiven to style that scrollbar.
SetsFont.enableSquareBracketsandFont.omitCurlyBraceseach to false onreplacementFont. This does not copy replacementFont; you can reuse an existing Font with those two fields set to false. Note that if you reuse a Font that is used in conjunction with markup, the modifications this makes to that Font will make that markup remain unparsed. You will typically want a different Font for your replacementFont used in TextraArea(s) than your Font(s) used elsewhere.
This gets a TextFieldStyle and a ScrollPaneStyle from skin. If a scene2d.ui TextFieldStyle is defined and an FWSkin (or subclass) reads in the Skin JSON file, this will be able to load the right TextFieldStyle from Styles in this package.- Parameters:
text- the initial text to hold in the TextraAreaskin- a scene2d.ui Skin, typically anFWSkinor one of its subclassesreplacementFont- a Font that will be modified in-place to diable brace/bracket markup parsing
-
TextraArea
public TextraArea(@Null String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName, String paneStyleName) Creates a TextraArea with the given initial text, skin to get styles from, and names of styles. UnlikeTextAreain scene2d.ui, this shows a scrollbar, so it needs aScrollPane.ScrollPaneStylegiven to style that scrollbar.
This gets a TextFieldStyle and a ScrollPaneStyle from skin. If a scene2d.ui TextFieldStyle is defined and an FWSkin (or subclass) reads in the Skin JSON file, this will be able to load the right TextFieldStyle from Styles in this package.- Parameters:
text- the initial text to hold in the TextraAreaskin- a scene2d.ui Skin, typically anFWSkinor one of its subclassesstyleName- the name of a TextFieldStyle in skinpaneStyleName- the name of a ScrollPaneStyle in skin
-
TextraArea
public TextraArea(String text, Styles.TextFieldStyle style, com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.ScrollPaneStyle paneStyle) Creates an InnerTextraArea with the given initial text and styles. UnlikeTextAreain scene2d.ui, this shows a scrollbar, so it needs aScrollPane.ScrollPaneStylegiven to style that scrollbar.
This assumes theStyles.TextFieldStyle.fonthas not been modified; the constructor for TextFieldStyle copies any Font given to it so this can setFont.enableSquareBracketsandFont.omitCurlyBraceseach to false on its copy without affecting other widget styles.- Parameters:
text- the initial text to hold in the TextraAreastyle- a TextFieldStyle fromStylespaneStyle- a scene2d.ui ScrollPaneStyle
-
TextraArea
public TextraArea(String text, Styles.TextFieldStyle style, com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.ScrollPaneStyle paneStyle, Font replacementFont) Creates a TextraArea with the given initial text, styles, and replacementFont. UnlikeTextAreain scene2d.ui, this shows a scrollbar, so it needs aScrollPane.ScrollPaneStylegiven to style that scrollbar.
SetsFont.enableSquareBracketsandFont.omitCurlyBraceseach to false onreplacementFont. This does not copy replacementFont; you can reuse an existing Font with those two fields set to false. Note that if you reuse a Font that is used in conjunction with markup, the modifications this makes to that Font will make that markup remain unparsed. You will typically want a different Font for your replacementFont used in TextraArea(s) than your Font(s) used elsewhere.- Parameters:
text- the initial text to hold in the TextraAreastyle- a TextFieldStyle fromStylespaneStyle- aScrollPane.ScrollPaneStylefrom scene2d.uireplacementFont- a Font that will be modified in-place to diable brace/bracket markup parsing
-
-
Method Details
-
getFont
-
setFont
-
sizeChanged
protected void sizeChanged()- Overrides:
sizeChangedin classcom.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
-