The TextField object is used to create display objects for text display and input. You can use the methods and properties of the TextField object to manipulate it with Lua Script.

To create a text field dynamically, use the TextField() constructor "new".


The methods of the TextField objects let you set, select, and manipulate text in a dynamic or input text field that you create during authoring or at runtime.


Lua Script provides several ways to format your text at runtime. The TextFormat object lets you set character and paragraph formatting for TextField objects. You can use built-in HTML tags, define new formatting tags. You can assign HTML formatted text directly to a text field.


Lu Studio supports a subset of HTML tags that you can use to format text. See the list of supported HTML tags in the description of the htmlText property.


Inherited from InteractiveObject -> DisplayObject -> EventDispatcher


Can be created with method new:

Lib.Media.Text.TextField.new()

Creates a new TextField instance.



Created TextField object has properties:

antiAliasType

The type of anti-aliasing used for this text field. (AntiAliasType)

autoSize

Controls automatic sizing and alignment of text fields. (TextFieldAutoSize)

background

Specifies whether the text field has a background fill. (true/false)

backgroundColor

The color of the text field background.

border

Specifies whether the text field has a border. (true/false)

borderColor

The color of the text field border.

bottomScrollV

[read-only] An integer (1-based index) that indicates the bottommost line that is currently visible in the specified text field.

defaultTextFormat

Specifies the format applied to newly inserted text, such as text entered by a user or text inserted with the replaceSelectedText() method. (TextFormat)

displayAsPassword

Specifies whether the text field is a password text field. (true/false)

embedFonts

Specifies whether to render by using embedded font outlines. (true/false)

gridFitType

The type of grid fitting used for this text field. (currently not supported)

htmlText

Contains the HTML representation of the text field contents.

length

[read-only] The number of characters in a text field.

caretIndex

[read-only] The index of the insertion point (caret) position.

maxChars

The maximum number of characters that the text field can contain, as entered by a user.

maxScrollH

[read-only] The maximum value of scrollH.

maxScrollV

[read-only] The maximum value of scrollV.

mouseWheelEnabled

A Boolean value that indicates whether application automatically scrolls multiline text fields when the user clicks a text field and rolls the mouse wheel. (true/false)

multiline

Indicates whether field is a multiline text field. (true/false)

numLines

[read-only] Defines the number of text lines in a multiline text field.

scrollH

The current horizontal scrolling position.

scrollV

The vertical position of text in a text field.

selectable

A Boolean value that indicates whether the text field is selectable.

selectionBeginIndex

[read-only] The zero-based character index value of the first character in the current selection.

selectionEndIndex

[read-only] The zero-based character index value of the last character in the current selection.

sharpness

The sharpness of the glyph edges in this text field.

text

A string that is the current text in the text field.

textColor

The color of the text in a text field, in hexadecimal format.

textHeight

[read-only] The height of the text in pixels.

textWidth

[read-only] The width of the text in pixels.

type

The type of the text field. (TextFieldType)

wordWrap

A Boolean value that indicates whether the text field has word wrap.


methods:

appendText(newText)

Appends the string specified by the newText parameter to the end of the text of the text field.

newText - The string to append to the existing text.

getCharBoundaries(charIndex)

Returns a rectangle that is the bounding box of the character.

charIndex - The zero-based index value for the character (for example, the first position is 0, the second position is 1, and so on).

getCharIndexAtPoint(x, y)

Returns the zero-based index value of the character at the point specified by the x and y parameters.

x - The x coordinate of the character.

y - The y coordinate of the character.


getFirstCharInParagraph(charIndex)

Given a character index, returns the index of the first character in the same paragraph.

charIndex - The zero-based index value of the character (for example, the first character is 0, the second character is 1, and so on).

getLineIndexAtPoint(x, y)

Returns the zero-based index value of the line at the point specified by the x and y parameters.

x - The x coordinate of the line.

y - The y coordinate of the line.

getLineIndexOfChar(charIndex)

Returns the zero-based index value of the line containing the character specified by the charIndex parameter.

charIndex - The zero-based index value of the character (for example, the first character is 0, the second character is 1, and so on).

getLineLength(lineIndex)

Returns the number of characters in a specific text line.

lineIndex - The line number for which you want the length.

getLineMetrics(lineIndex)

Returns metrics information about a given text line. 

TextLineMetrics object has properties:

 x:Float

 width:Float

 height:Float

 ascent:Float

 descent:Float

 leading:Float

lineIndex - The line number for which you want metrics information.

getLineOffset(lineIndex)

Returns the character index of the first character in the line that the lineIndex parameter specifies.

lineIndex - The zero-based index value of the line (for example, the first line is 0, the second line is 1, and so on).

getLineText(lineIndex)

Returns the text of the line specified by the lineIndex parameter.

lineIndex - The zero-based index value of the line (for example, the first line is 0, the second line is 1, and so on).

getParagraphIndexOfChar(charIndex)

Returns the zero-based index value of the paragraph containing the character specified by the charIndex parameter.

charIndex - The zero-based index value of the character (for example, the first character is 0, the second character is 1, and so on).

getTextFormat(beginIndex, endIndex)

Returns a TextFormat object that contains formatting information for the range of text that the beginIndex and endIndex parameters specify.

beginIndex - (default = -1) - an integer that specifies the starting location of a range of text within the text field.

endIndex - (default = -1) - an integer that specifies the position of the first character after the desired text span. As designed, if you specify beginIndex and endIndex values, the text from beginIndex to endIndex-1 is read.

getTextRuns(beginIndex, endIndex)

Returns table of TextRun objects with fields:


beginIndex - the zero-based index value for the start position of the TextRun.


endIndex - the zero-based index position of the first character after the this TextRun.


textFormat - TextFormat object that contains formatting information for the range of returned TextRun object with the beginIndex and endIndex fields position. 

beginIndex - (default = -1) - an integer that specifies the starting location of a range of text within the text field.

endIndex - (default = -1) - an integer that specifies the position of the first character after the desired text span. As designed, if you specify beginIndex and endIndex values, the text from beginIndex to endIndex-1 is read.

replaceText(beginIndex, endIndex, newText)

Replaces the range of characters that the beginIndex and endIndex parameters specify with the contents of the newText parameter.

beginIndex - The zero-based index value for the start position of the replacement range.

endIndex - The zero-based index position of the first character after the desired text span.

newText - The text to use to replace the specified range of characters.

setSelection(beginIndex, endIndex)

Sets as selected the text designated by the index values of the first and last characters, which are specified with the beginIndex and endIndex parameters.

beginIndex - The zero-based index value of the first character in the selection (for example, the first character is 0, the second character is 1, and so on).

endIndex - The zero-based index value of the last character in the selection.

setTextFormat(format, beginIndex, endIndex)

Applies the text formatting that the format parameter specifies to the specified text in a text field.

format - A TextFormat object that contains character and paragraph formatting information.

beginIndex - (default = -1) - an integer that specifies the zero-based index position specifying the first character of the desired range of text.

endIndex - (default = -1) - an integer that specifies the first character after the desired text span. As designed, if you specify beginIndex and endIndex values, the text from beginIndex to endIndex-1 is updated.


TextField Events:

  • TextEvent
  • Lib.Media.Events.Event.CHANGE
  • Lib.Media.Events.Event.SCROLL


Created with the Personal Edition of HelpNDoc: Create cross-platform Qt Help files