APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.badlogic.gdx.scenes.scene2d.ui

public Class TextArea

extends TextField
Class Inheritance
Imports
com.badlogic.gdx.Gdx, .Input, com.badlogic.gdx.graphics.g2d.Batch, .BitmapFont, .GlyphLayout, com.badlogic.gdx.scenes.scene2d.InputEvent, .InputListener, com.badlogic.gdx.scenes.scene2d.utils.Drawable, com.badlogic.gdx.utils.Align, .IntArray, .Null, .Pool

A text input field with multiple lines.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class
TextArea.TextAreaListener

Input listener for the text area

Field Summary

Modifier and TypeField and Description
pack-priv int
cursorLine

Current line for the cursor

pack-priv int
firstLineShowing

Index of the first line showed by the text area

private String
lastText

Last text processed.

pack-priv IntArray
linesBreak

Array storing lines breaks positions

private int
linesShowing

Number of lines showed by the text area

pack-priv float
moveOffset

Variable to maintain the x offset of the cursor when moving up and down.

private float
Inherited from com.badlogic.gdx.scenes.scene2d.ui.TextField:
BACKSPACEblinkTaskblinkTimeBULLETCARRIAGE_RETURNclipboardcursorcursorOnDEFAULT_ONSCREEN_KEYBOARDDELETEdisableddisplayTextfilterfocusedfocusTraversalfontOffsetglyphPositionshasSelectioninputListenerkeyboardkeyRepeatInitialTimekeyRepeatTaskkeyRepeatTimelayoutlistenerNEWLINEonlyFontCharspasswordModeprogrammaticChangeEventsrenderOffsetselectionStartstyleTABtexttextHeighttextOffsetundoMaxvisibleTextEndvisibleTextStartwriteEnters

Constructor Summary

AccessConstructor and Description
public
TextArea(String text, Skin skin)

public
TextArea(String text, Skin skin, String styleName)

public

Method Summary

Modifier and TypeMethod and Description
private int
calculateCurrentLineIndex(int cursor)

Calculates the text area line for the given cursor position

protected void
protected boolean
protected InputListener
protected void
drawCursor(Drawable cursorPatch, Batch batch, BitmapFont font, float x, float y)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.drawCursor.

protected void
drawSelection(Drawable selection, Batch batch, BitmapFont font, float x, float y)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.drawSelection.

Draws selection rectangle

protected void
public int
public float
public float
public int
public int
getLines()

Returns total number of lines that the text occupies

public int
public float
protected float
protected void
protected int
protected void
public void
moveCursorLine(int line)

Moves the cursor to the given number line

public boolean
newLineAtEnd()

Returns if there's a new line at then end of the text

public void
setPrefRows(float prefRows)

Sets the preferred number of rows (lines) for this text area.

public void
setSelection(int selectionStart, int selectionEnd)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.setSelection.

Sets the selected text.

public void
pack-priv void
showCursor()

Scroll the text area to show the line of the cursor

protected void
sizeChanged()

Overrides com.badlogic.gdx.scenes.scene2d.ui.Widget.sizeChanged.

Called when the actor's size has been changed.

pack-priv void
updateCurrentLine()

Updates the current line, checking the cursor position in the text

pack-priv void
Inherited from com.badlogic.gdx.scenes.scene2d.ui.TextField:
appendTextchangeTextclearSelectioncopycutcutdeletedrawdrawBackgrounddrawMessageTextgetAlignmentgetBackgroundDrawablegetCursorPositiongetDefaultInputListenergetFocusTraversalgetMaxLengthgetMessageTextgetOnscreenKeyboardgetPrefWidthgetProgrammaticChangeEventsgetSelectiongetSelectionStartgetStylegetTextgetTextFieldFilterinsertisDisabledisPasswordModeisWordCharacternextpasteredoredoselectAllsetAlignmentsetAutocompleteOptionssetBlinkTimesetClipboardsetCursorPositionsetDisabledsetFocusTraversalsetKeyboardTypesetMaxLengthsetMessageTextsetOnlyFontCharssetOnscreenKeyboardsetPasswordCharactersetPasswordModesetPreventAutoCorrectionsetProgrammaticChangeEventssetTextsetTextFieldFiltersetTextFieldListenerundoundoupdateDisplayTextwithinMaxLengthwordUnderCursorwordUnderCursor

Field Detail

cursorLineback to summary
pack-priv int cursorLine

Current line for the cursor

firstLineShowingback to summary
pack-priv int firstLineShowing

Index of the first line showed by the text area

lastTextback to summary
private String lastText

Last text processed. This attribute is used to avoid unnecessary computations while calculating offsets

linesBreakback to summary
pack-priv IntArray linesBreak

Array storing lines breaks positions

linesShowingback to summary
private int linesShowing

Number of lines showed by the text area

moveOffsetback to summary
pack-priv float moveOffset

Variable to maintain the x offset of the cursor when moving up and down. If it's set to -1, the offset is reset

prefRowsback to summary
private float prefRows

Constructor Detail

TextAreaback to summary
public TextArea(String text, Skin skin)
TextAreaback to summary
public TextArea(String text, Skin skin, String styleName)
TextAreaback to summary
public TextArea(String text, TextField.TextFieldStyle style)

Method Detail

calculateCurrentLineIndexback to summary
private int calculateCurrentLineIndex(int cursor)

Calculates the text area line for the given cursor position

calculateOffsetsback to summary
protected void calculateOffsets()

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.calculateOffsets.

continueCursorback to summary
protected boolean continueCursor(int index, int offset)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.continueCursor.

createInputListenerback to summary
protected InputListener createInputListener()

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.createInputListener.

drawCursorback to summary
protected void drawCursor(Drawable cursorPatch, Batch batch, BitmapFont font, float x, float y)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.drawCursor.

drawSelectionback to summary
protected void drawSelection(Drawable selection, Batch batch, BitmapFont font, float x, float y)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.drawSelection.

Doc from com.badlogic.gdx.scenes.scene2d.ui.TextField.drawSelection.

Draws selection rectangle

drawTextback to summary
protected void drawText(Batch batch, BitmapFont font, float x, float y)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.drawText.

getCursorLineback to summary
public int getCursorLine()
getCursorXback to summary
public float getCursorX()
getCursorYback to summary
public float getCursorY()
getFirstLineShowingback to summary
public int getFirstLineShowing()
getLinesback to summary
public int getLines()

Returns total number of lines that the text occupies

getLinesShowingback to summary
public int getLinesShowing()
getPrefHeightback to summary
public float getPrefHeight()

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.getPrefHeight.

Implements com.badlogic.gdx.scenes.scene2d.utils.Layout.getPrefHeight.

getTextYback to summary
protected float getTextY(BitmapFont font, Drawable background)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.getTextY.

initializeback to summary
protected void initialize()

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.initialize.

letterUnderCursorback to summary
protected int letterUnderCursor(float x)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.letterUnderCursor.

moveCursorback to summary
protected void moveCursor(boolean forward, boolean jump)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.moveCursor.

moveCursorLineback to summary
public void moveCursorLine(int line)

Moves the cursor to the given number line

newLineAtEndback to summary
public boolean newLineAtEnd()

Returns if there's a new line at then end of the text

setPrefRowsback to summary
public void setPrefRows(float prefRows)

Sets the preferred number of rows (lines) for this text area. Used to calculate preferred height

setSelectionback to summary
public void setSelection(int selectionStart, int selectionEnd)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.setSelection.

Doc from com.badlogic.gdx.scenes.scene2d.ui.TextField.setSelection.

Sets the selected text.

setStyleback to summary
public void setStyle(TextField.TextFieldStyle style)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.setStyle.

Implements com.badlogic.gdx.scenes.scene2d.ui.Styleable.setStyle.

Doc from com.badlogic.gdx.scenes.scene2d.ui.Styleable.setStyle.

Set the current style of the actor

showCursorback to summary
pack-priv void showCursor()

Scroll the text area to show the line of the cursor

sizeChangedback to summary
protected void sizeChanged()

Overrides com.badlogic.gdx.scenes.scene2d.ui.Widget.sizeChanged.

Doc from com.badlogic.gdx.scenes.scene2d.Actor.sizeChanged.

Called when the actor's size has been changed.

updateCurrentLineback to summary
pack-priv void updateCurrentLine()

Updates the current line, checking the cursor position in the text

updateFirstLineShowingback to summary
pack-priv void updateFirstLineShowing()
com.badlogic.gdx.scenes.scene2d.ui back to summary

public Class TextArea.TextAreaListener

extends TextFieldClickListener
Class Inheritance

Input listener for the text area

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected boolean
checkFocusTraversal(char character)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldClickListener.checkFocusTraversal.

Checks if focus traversal should be triggered.

protected void
protected void
public boolean
keyDown(InputEvent event, int keycode)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldClickListener.keyDown.

Called when a key goes down.

public boolean
keyTyped(InputEvent event, char character)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldClickListener.keyTyped.

Called when a key is typed.

protected void
Inherited from com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldClickListener:
clickedkeyUpscheduleKeyRepeatTasktouchDowntouchDraggedtouchUp

Constructor Detail

TextAreaListenerback to summary
public TextAreaListener()

Method Detail

checkFocusTraversalback to summary
protected boolean checkFocusTraversal(char character)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldClickListener.checkFocusTraversal.

Doc from com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldClickListener.checkFocusTraversal.

Checks if focus traversal should be triggered. The default implementation uses TextField#focusTraversal and the typed character, depending on the OS.

goEndback to summary
protected void goEnd(boolean jump)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldClickListener.goEnd.

goHomeback to summary
protected void goHome(boolean jump)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldClickListener.goHome.

keyDownback to summary
public boolean keyDown(InputEvent event, int keycode)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldClickListener.keyDown.

Doc from com.badlogic.gdx.scenes.scene2d.InputListener.keyDown.

Called when a key goes down. When true is returned, the event is handled.

keyTypedback to summary
public boolean keyTyped(InputEvent event, char character)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldClickListener.keyTyped.

Doc from com.badlogic.gdx.scenes.scene2d.InputListener.keyTyped.

Called when a key is typed. When true is returned, the event is handled.

setCursorPositionback to summary
protected void setCursorPosition(float x, float y)

Overrides com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldClickListener.setCursorPosition.