class TextFieldRTL
package texter.openfl
extends Sprite › DisplayObjectContainer › InteractiveObject › DisplayObject › EventDispatcher
TextFieldRTL
is an "extention" of TextField
that adds support for multiple things:
- right-to-left text
- built-in markdown visualization
It also adds some convenience methods & fields for working with the object, that TextField
doesn't have:
- alignment
- overlay
- underlay
- markdownText
- editable
caretIndex
- hasFocus
- insertSubstring()
- getCaretIndexAtPoint()
- getCaretIndexOfMouse()
And more.
Constructor
Variables
alignment:TextFieldAutoSize
Controls automatic sizing and alignment of this TextFieldRTL
.
| mode | description |
| --- | --- |
| TextFieldAutoSize.NONE
| no automatic sizing or alignment |
| TextFieldAutoSize.LEFT
| the text is treated as left-justified text, meaning that the left margin of the text field remains fixed and any resizing of a single line of the text field is on the right margin. If the text includes a line break(for example, "\n"
or "\r"
), the bottom is also resized to fit the next line of text. If wordWrap
is also set to true
, only the bottom of the text field is resized and the right side remains fixed. |
| TextFieldAutoSize.RIGHT
| the text is treated as right-justified text, meaning that the right margin of the text field remains fixed and any resizing of a single line of the text field is on the left margin. If the text includes a line break(for example, "\n" or "\r")
, the bottom is also resized to fit the next line of text. If wordWrap
is also set to true
, only the bottom of the text field is resized and the left side remains fixed.
| TextFieldAutoSize.CENTER
| the text is treated as center-justified text, meaning that any resizing of a single line of the text field is equally distributed to both the right and left margins. If the text includes a line break(for example, "\n"
or "\r"
), the bottom is also resized to fit the next line of text. If wordWrap
is also set to true
, only the bottom of the text field is resized and the left and right sides remain fixed.|
autoAlign:Bool = true
Whether or not the text is aligned according to the first typed character:
- if the character is from a RTL language -
alignment
will be set toRIGHT
. - if the character is from any other language -
alignment
will be set toLEFT
. -
if the character is not from any specific language -
alignment
will be set toUNDETERMINED
.**`autoAlign` does not default to a certine direction when set to `false`**. it will use the last direction it remembers when this `TextFieldRTL` was created/when `autoAlign` was still true;
autoSize:TextFieldAutoSize
Similar to the alignment
property of TextFieldRTL
, and only exists for compatibility with TextField
.
The reason for adding the alignment
property in the first place is to make it easier to use TextFieldRTL
objects.
background:Bool
Whether or not this TextFieldRTL
has a background.
*
* **Note** - when using the `underlay` property, you might want to set this property to false to avoid hiding the `underlay`.
backgroundColor:Int
The default background color that will be used to draw the text.
Note - when using the underlay
property, you might want to set the background
property
to false. this also means the color applied here wont do anything. If you want to color the underlay
's
background, you can do this:
underlay.graphics.beginFill(yourColor);
underlay.graphics.drawRect(0, 0, textField.width, textField.textHeight);
underlay.graphics.endFill();
borderColor:Int
The color of the text field border. The default value is
0x000000
(black). This property can be retrieved or set, even
if there currently is no border. the color is visible only
if the text field has the border
property set to true
.
caretIndex:Int = 0
Similar to TextField
s caretIndex, but its editable.
The caret is the blinking cursor that appears when you're typing. its always before the character you're typing.
For example (⸽
is the caret): index - 0
empty text field:
▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
▏⸽ ▎
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
caret at the end of the text field: index - text.length
▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
▏hey there friend⸽ ▎
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
caret at index 1 (after the first character at index 0
): index - 1
▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
▏h⸽ey there friend ▎
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
defaultTextFormat:TextFormat
Specifies the format applied to newly inserted text, such as text entered
by a user or text inserted with the replaceSelectedText()
method.
Note: When selecting characters to be replaced with
setSelection()
and replaceSelectedText()
, the
defaultTextFormat
will be applied only if the text has been
selected up to and including the last character. Here is an example:
var textField:TextField = new TextField();
textField.text = "Flash Macintosh version";
var format:TextFormat = new TextFormat();
format.color = 0xFF0000;
textField.defaultTextFormat = format;
textField.setSelection(6,15); // partial text selected - defaultTextFormat not applied
textField.setSelection(6,23); // text selected to end - defaultTextFormat applied
textField.replaceSelectedText("Windows version");
When you access the defaultTextFormat
property, the
returned TextFormat object has all of its properties defined. No property
is null
.
Note: You can't set this property if a style sheet is applied to the text field.
hasFocus:Bool
Whether or not this field of text is currently in focus.
In INPUT mode, when the user clicks on the textfield, it will gain focus and the user can start typing. In STAIC and DYNAMIC modes, the textfield gains focus whenever the user clicks on it/starts selecting text.
htmlText:UTF8String
Contains the HTML representation of the text field contents. Flash Player supports the following HTML tags:
Tag | Description |
---|---|
Anchor tag | The <a> tag creates a hypertext link and supports the following attributes:
|
Bold tag | The <b> tag renders text as bold. A bold typeface must be available for the font used. |
Break tag | The <br> tag creates a line break in the text field. Set the text field to be a multiline text field to use this tag. |
Font tag | The <font> tag specifies a font or list of fonts to display the text.The font tag supports the following attributes:
|
Image tag | The <img> tag lets you embed external image files (JPEG, GIF, PNG), SWF files, and movie clips inside text fields. Text automatically flows around images you embed in text fields. You must set the text field to be multiline to wrap text around an image.The <img> tag supports the following attributes:
<img> tag height and width attributes. In general, an image embedded in a text field appears on the line following the <img> tag. However, when the <img> tag is the first character in the text field, the image appears on the first line of the text field.For AIR content in the application security sandbox, AIR ignores img tags in HTML content in ActionScript TextField objects. This is to prevent possible phishing attacks. |
Italic tag | The <i> tag displays the tagged text in italics. An italic typeface must be available for the font used. |
List item tag | The <li> tag places a bullet in front of the text that it encloses.Note: Because Flash Player and AIR do not recognize ordered and unordered list tags ( <ol> and <ul> , they do not modify how your list is rendered. All lists are unordered and all list items use bullets. |
Paragraph tag | The <p> tag creates a new paragraph. The text field must be set to be a multiline text field to use this tag. The <p> tag supports the following attributes:
|
Span tag | The <span> tag is available only for use with CSS text styles. It supports the following attribute:
|
Text format tag | The <textformat> tag lets you use a subset of paragraph formatting properties of the TextFormat class within text fields, including line leading, indentation, margins, and tab stops. You can combine <textformat> tags with the built-in HTML tags.The <textformat> tag has the following attributes:blockindent : Specifies the block indentation in points; corresponds to TextFormat.blockIndent .indent : Specifies the indentation from the left margin to the first character in the paragraph; corresponds to TextFormat.indent . Both positive and negative numbers are acceptable.leading : Specifies the amount of leading (vertical space) between lines; corresponds to TextFormat.leading . Both positive and negative numbers are acceptable.leftmargin : Specifies the left margin of the paragraph, in points; corresponds to TextFormat.leftMargin .rightmargin : Specifies the right margin of the paragraph, in points; corresponds to TextFormat.rightMargin .tabstops : Specifies custom tab stops as an array of non-negative integers; corresponds to TextFormat.tabStops . |
Underline tag | The <u> tag underlines the tagged text. |
Flash Player and AIR support the following HTML entities:
Entity | Description |
---|---|
< | < (less than) |
> | > (greater than) |
& | & (ampersand) |
" | " (double quotes) |
' | ' (apostrophe, single quote) |
Flash Player and AIR also support explicit character codes, such as & (ASCII ampersand) and € (Unicode € symbol).
markdownText:String
Contains a markdown formatted string.
When set, it will be parsed and the resulting text will be displayed with the corresponding markup
*more information in Markdown
and MarkdownVisualizer
classes
maxChars:Int
The maximum number of characters that the text field can contain, as entered
by a user. A script can insert more text than
maxChars
allows; the maxChars
property indicates only how much text a
user can enter. If the value of this property is 0
, a user can enter an
unlimited amount of text.
multiline:Bool
Whether or not this field of text will accept multiline
input (make another line when adding a \n
)
read onlyopeningDirection:TextDirection = UNDETERMINED
Specifies the direction of the starting character inside this text input.
the text direction will only be set according to openingDirection
if autoAlign
is set to true.
openingDirection
is decided after the first strongly typed character is typed. a table to help:
Character Group | Type | Direction |
---|---|---|
punctuation marks (see CharTools.generalMarks ) | softly typed | UNDETERMINED |
LTR languages (English, Spanish, French, German...) | strongly typed | LTR |
RTL languages (Arabic, Hebrew, Sorani, Urdu...) | strongly typed | RTL |
overlay:Sprite
This Sprite
is a "mask" that exists above the actual text. You can
draw on it, add DisplayObject
s to it, etc.
scrollH:Int
The current horizontal scrolling position. If the scrollH
property is 0, the text is not horizontally scrolled. This property value
is an integer that represents the horizontal position in pixels.
The units of horizontal scrolling are pixels, whereas the units of vertical scrolling are lines. Horizontal scrolling is measured in pixels because most fonts you typically use are proportionally spaced; that is, the characters can have different widths. Flash Player performs vertical scrolling by line because users usually want to see a complete line of text rather than a partial line. Even if a line uses multiple fonts, the height of the line adjusts to fit the largest font in use.
Note: The scrollH
property is zero-based, not
1-based like the scrollV
vertical scrolling property.
scrollV:Int
The vertical position of text in a text field. The scrollV
property is useful for directing users to a specific paragraph in a long
passage, or creating scrolling text fields.
The units of vertical scrolling are lines, whereas the units of horizontal scrolling are pixels. If the first line displayed is the first line in the text field, scrollV is set to 1(not 0). Horizontal scrolling is measured in pixels because most fonts are proportionally spaced; that is, the characters can have different widths. Flash performs vertical scrolling by line because users usually want to see a complete line of text rather than a partial line. Even if there are multiple fonts on a line, the height of the line adjusts to fit the largest font in use.
selectable:Bool
A Boolean value that indicates whether the text field is selectable. The
value true
indicates that the text is selectable. The
selectable
property controls whether a text field is
selectable, not whether a text field is editable. A dynamic text field can
be selectable even if it is not editable. If a dynamic text field is not
selectable, the user cannot select its text.
If selectable
is set to false
, the text in
the text field does not respond to selection commands from the mouse or
keyboard, and the text cannot be copied with the Copy command. If
selectable
is set to true
, the text in the text
field can be selected with the mouse or keyboard, and the text can be
copied with the Copy command. You can select text this way even if the
text field is a dynamic text field instead of an input text field.
defaults to true.
type:TextFieldType
The type of the text field.
| mode | description |
| --- | --- |
| TextFieldType.DYNAMIC
| If you load text into the TextField
by using the text
or htmlText
property and then you want to display the loaded text, set the type
property of the TextField
to TextFieldType.DYNAMIC
.
| TextFieldType.INPUT
| If you do not want the text in the TextField
to be editable, set the type
property of the TextField
to TextFieldType.INPUT
.
underlay:Sprite
This Sprite
is a "mask" that exists below the actual text. You can
draw on it, add DisplayObject
s to it, etc.
NOTICE - setting the background
property to true
will hide the underlay.
wordWrap:Bool
Whether or not the this textfield will try to escape words that are too long to fit in the textfield.
without wordWrap (whats outside of the textfield isnt visible):
▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
▏hello there everyone▎its your friend here
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
with wordWrap:
▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
▏hello there everyone▎
▏its your friend here▎
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔