import { InteractiveObject } from '../display/InteractiveObject';
import { TextFormat } from './TextFormat';
import { StyleSheet } from './StyleSheet';
import { Rectangle } from '../geom/Rectangle';
import { TextLineMetrics } from './TextLineMetrics';
import { DisplayObject } from '../display/DisplayObject';
import { DisplayObject as AwayDisplayObject, TextField as AwayTextField, TextFieldType } from '@awayjs/scene';
/**
* Flash Player dispatches the textInteractionModeChange event when a user
* changes the interaction mode of a text field.
[Event(name="textInteractionModeChange", type="flash.events.Event")]
* Flash Player dispatches the textInput event when a user enters one or more
* characters of text.
* @eventType flash.events.TextEvent.TEXT_INPUT
[Event(name="textInput", type="flash.events.TextEvent")]
* Dispatched by a TextField object after the user scrolls.
* @eventType flash.events.Event.SCROLL
[Event(name="scroll", type="flash.events.Event")]
* Dispatched when a user clicks a hyperlink in an
* HTML-enabled text field, where the URL begins with "event:".
* @eventType flash.events.TextEvent.LINK
*
[Event(name="link", type="flash.events.TextEvent")]
* Dispatched after a control value is modified, unlike
* the textInput event, which is dispatched before the value is modified.
* @eventType flash.events.Event.CHANGE
[Event(name="change", type="flash.events.Event")]
* The TextField class is used to create display objects for text display and input.
*
To create a text field dynamically,
* use the
* The methods of the TextField class let you set, select, and manipulate text in a dynamic or input * text field that you create during authoring or at runtime.
*ActionScript provides several ways to
* format your text at runtime. The TextFormat class lets you set character and paragraph formatting
* for TextField objects. You can apply Cascading Style Sheets (CSS) styles
* to text fields by using the
Flash Player 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
to place line breaks in the text field.
* Set the condenseWhite property before setting the htmlText property.
*/
get condenseWhite(): boolean;
set condenseWhite(value: boolean);
/**
* 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 my_txt:TextField new TextField();
* my_txt.text = "Flash Macintosh version";
* var my_fmt:TextFormat = new TextFormat();
* my_fmt.color = 0xFF0000;
* my_txt.defaultTextFormat = my_fmt;
* my_txt.setSelection(6,15); // partial text selected - defaultTextFormat not applied
* my_txt.setSelection(6,23); // text selected to end - defaultTextFormat applied
* my_txt.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.
* @throws Error This method cannot be used on a text field with a style sheet.
*/
get defaultTextFormat(): TextFormat;
set defaultTextFormat(format: TextFormat);
/**
* Specifies whether the text field is a password text field. If the value of this property is true,
* the text field is treated as a password text field and hides the input characters using asterisks instead of the
* actual characters. If false, the text field is not treated as a password text field. When password mode
* is enabled, the Cut and Copy commands and their corresponding keyboard shortcuts will
* not function. This security mechanism prevents an unscrupulous user from using the shortcuts to discover
* a password on an unattended computer.
*/
get displayAsPassword(): boolean;
set displayAsPassword(value: boolean);
/**
* Specifies whether to render by using embedded font outlines.
* If false, Flash Player renders the text field by using
* device fonts.
*
* If you set the embedFonts property to true for a text field,
* you must specify a font for that text by using the font property of
* a TextFormat object applied to the text field.
* If the specified font is not embedded in the SWF file, the text is not displayed.
*/
get embedFonts(): boolean;
set embedFonts(value: boolean);
/**
* The type of grid fitting used for this text field. This property applies only if the
* flash.text.AntiAliasType property of the text field is set to flash.text.AntiAliasType.ADVANCED.
*
* The type of grid fitting used determines whether Flash Player forces strong horizontal and
* vertical lines to fit to a pixel or subpixel grid, or not at all.
* For the flash.text.GridFitType property, you can use the following string values:String value
* Descriptionflash.text.GridFitType.NONE
* Specifies no grid fitting. Horizontal and vertical lines in the glyphs are not
* forced to the pixel grid. This setting is recommended for animation or
* for large font sizes.flash.text.GridFitType.PIXEL
* Specifies that strong horizontal and vertical lines are fit to the
* pixel grid. This setting works only for left-aligned text fields.
* To use this setting, the flash.dispaly.AntiAliasType property of the text field
* must be set to flash.text.AntiAliasType.ADVANCED.
* This setting generally provides the best legibility for
* left-aligned text.flash.text.GridFitType.SUBPIXEL
* Specifies that strong horizontal and vertical lines are fit to the subpixel grid on
* an LCD monitor. To use this setting, the
* flash.text.AntiAliasType property of the text field must be set to
* flash.text.AntiAliasType.ADVANCED. The flash.text.GridFitType.SUBPIXEL setting is often good
* for right-aligned or centered
* dynamic text, and it is sometimes a useful trade-off for animation versus text quality.
*/
get gridFitType(): string;
set gridFitType(gridFitType: string);
/**
* Contains the HTML representation of the text field contents.
*
* Flash Player supports the following HTML tags:
* Tag
*
* Description
*
* Anchor tag
*
* The tag creates a hypertext link and supports the following attributes:
* target: Specifies the name of the target window where you load the page.
* Options include _self, _blank, _parent, and
* _top. The _self option specifies the current frame in the current window,
* _blank specifies a new window, _parent specifies the parent of the
* current frame, and _top specifies the top-level frame in the current window.
* href: Specifies a URL or an ActionScript link event.The URL can
* be either absolute or relative to the location of the SWF file that
* is loading the page. An example of an absolute reference to a URL is
* http://www.adobe.com; an example of a relative reference is
* /index.html. Absolute URLs must be prefixed with
* http://; otherwise, Flash Player or AIR treats them as relative URLs.
*
* You can use the link event to cause the link to execute an ActionScript
* function in a SWF file instead of opening a URL. To specify a link event, use
* the event scheme instead of the http scheme in your href attribute. An example
* is href="event:myText" instead of href="http://myURL"; when the
* user clicks a hypertext link that contains the event scheme, the text field dispatches a
* link TextEvent with its text property set to "myText". You can then create an ActionScript
* function that executes whenever the link TextEvent is dispatched.
*
* You can also define a:link, a:hover, and a:active
* styles for anchor tags by using style sheets.
*
* Bold tag
*
* The tag renders text as bold. A bold typeface must be available for the font used.
*
* Break tag
*
* The tag creates a new paragraph. The text field must be set to be a multiline
* text field to use this tag.
*
* The tag supports the following attributes:
*
* align: Specifies alignment of text within the paragraph; valid values are left, right, justify, and center.
*
* class: Specifies a CSS style class defined by a flash.text.StyleSheet object.
*
* Span tag
*
* The tag is available only for use with CSS text styles. It supports the
* following attribute:
*
* class: Specifies a CSS style class defined by a flash.text.StyleSheet object.
*
* Text format tag
* The
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 tag specifies a font or list of fonts to display the text.The font tag
* supports the following attributes:
* color: Only hexadecimal color (#FFFFFF) values are supported.
* face: Specifies the name of the font to use. As shown in the following example,
* you can specify a list of comma-delimited font names, in which case Flash Player selects the first available
* font. If the specified font is not installed on the local computer system or isn't embedded in the SWF file,
* Flash Player selects a substitute font.
* size: Specifies the size of the font. You can use absolute pixel sizes, such as 16 or 18,
* or relative point sizes, such as +2 or -4.
*
* Image tag
*
* The 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
tag supports the following attributes: src:
* Specifies the URL to an image or SWF file, or the linkage identifier for a movie clip
* symbol in the library.
* This attribute is required; all other attributes are optional. External files (JPEG, GIF, PNG,
* and SWF files) do not show until they are downloaded completely.
* width: The width of the image, SWF file, or movie clip being inserted, in pixels.
* height: The height of the image, SWF file, or movie clip being inserted, in pixels.
* align: Specifies the horizontal alignment of the embedded image within the text field.
* Valid values are left and right. The default value is left.
* hspace: Specifies the amount of horizontal space that surrounds the image where
* no text appears. The default value is 8.
* vspace: Specifies the amount of vertical space that surrounds the image where no
* text appears. The default value is 8.
* id: Specifies the name for the movie clip instance (created by Flash Player) that contains
* the embedded image file, SWF file, or movie clip. This approach is used to control the embedded content with
* ActionScript.
* checkPolicyFile: Specifies that Flash Player checks for a URL policy file
* on the server associated with the image domain. If a policy file exists, SWF files in the domains
* listed in the file can access the data of the loaded image, for example, by calling the
* BitmapData.draw() method with this image as the source parameter.
* For more information related to security, see the Flash Player Developer Center Topic:
* Security.
*
* Flash displays media embedded in a text field at full size. To specify the dimensions of the media
* you are embedding, use the
tag height and width
* attributes. In general, an image embedded in a text field appears on the line following the
*
tag. However, when the
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 tag displays the tagged text in italics. An italic typeface must be available
* for the font used.
*
* List item tag
*
* The
* and
, they do not modify how your list is rendered. All lists are unordered and all
* list items use bullets.
*
* Paragraph tag
*
* The
tag.
* The
tag is in the following format:
*
*
* @param id The id to match (in the id attribute of the
* tag).
* @return The display object corresponding to the image or SWF file with the matching id
* attribute in the
tag of the text field. For media loaded from an external source,
* this object is a Loader object, and, once loaded, the media object is a child of that Loader object. For media
* embedded in the SWF file, it is the loaded object. If no
tag with
* the matching id exists, the method returns null.
*/
getImageReference(id: string): DisplayObject;
/**
* Returns the zero-based index value of the line at the point specified by the x
* and y parameters.
* @param x The x coordinate of the line.
* @param y The y coordinate of the line.
* @return The zero-based index value of the line (for example, the first line is 0, the
* second line is 1, and so on). Returns -1 if the point is not over any line.
*/
getLineIndexAtPoint(x: number, y: number): number;
/**
* Returns the zero-based index value of the line containing the character specified
* by the charIndex parameter.
* @param charIndex The zero-based index value of the character (for example, the first character is 0,
* the second character is 1, and so on).
* @return The zero-based index value of the line.
*/
getLineIndexOfChar(charIndex: number): number;
/**
* Returns the number of characters in a specific text line.
* @param lineIndex The line number for which you want the length.
* @return The number of characters in the line.
* @throws RangeError The line number specified is out of range.
*/
getLineLength(lineIndex: number): number;
/**
* Returns metrics information about a given text line.
* @param lineIndex The line number for which you want metrics information.
* @return A TextLineMetrics object.
* @throws RangeError The line number specified is out of range.
*/
getLineMetrics(lineIndex: number): TextLineMetrics;
/**
* Returns the character index of the first character in the line that
* the lineIndex parameter specifies.
* @param lineIndex The zero-based index value of the line (for example, the first line is 0,
* the second line is 1, and so on).
* @return The zero-based index value of the first character in the line.
* @throws RangeError The line number specified is out of range.
*/
getLineOffset(lineIndex: number): number;
/**
* Returns the text of the line specified by the lineIndex parameter.
* @param lineIndex The zero-based index value of the line (for example, the first line is 0,
* the second line is 1, and so on).
* @return The text string contained in the specified line.
* @throws RangeError The line number specified is out of range.
*/
getLineText(lineIndex: number): string;
/**
* Given a character index, returns the length of the paragraph containing the given character.
* The length is relative to the first character in the paragraph (as returned by
* getFirstCharInParagraph()), not to the character index passed in.
* @param charIndex The zero-based index value of the character (for example, the first character is 0,
* the second character is 1, and so on).
* @return Returns the number of characters in the paragraph.
* @throws RangeError The character index specified is out of range.
*/
getParagraphLength(charIndex: number): number;
getRawText(): string;
/**
* Returns a TextFormat object that contains formatting information for the range of text that the
* beginIndex and endIndex parameters specify. Only properties
* that are common to the entire text specified are set in the resulting TextFormat object.
* Any property that is mixed, meaning that it has different values
* at different points in the text, has a value of null.
*
* If you do not specify
* values for these parameters, this method is applied to all the text in the text field.
* The following table describes three possible usages:UsageDescriptionmy_textField.getTextFormat()
* Returns a TextFormat object containing formatting information for all text in a text field.
* Only properties that are common to all text in the text field are set in the resulting TextFormat
* object. Any property that is mixed, meaning that it has different values at different
* points in the text, has a value of null.my_textField.getTextFormat(beginIndex:Number)
* Returns a TextFormat object containing a copy of the text format of the character at the
* beginIndex position.my_textField.getTextFormat(beginIndex:Number,endIndex:Number)
* Returns a TextFormat object containing formatting information for the span of
* text from beginIndex to endIndex-1. Only properties that are common
* to all of the text in the specified range are set in the resulting TextFormat object. Any property
* that is mixed (that is, has different values at different points in the range) has its value set to null.
* @param beginIndex Optional; an integer that specifies the starting location
* of a range of text within the text field.
* @param endIndex Optional; 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.
* @return The TextFormat object that represents the formatting properties for the specified text.
* @throws RangeError The beginIndex or endIndex specified is out of range.
*/
getTextFormat(beginIndex?: number, endIndex?: number): TextFormat;
getTextRuns(beginIndex?: number, endIndex?: number): any[];
getXMLText(beginIndex?: number, endIndex?: number): string;
insertXMLText(beginIndex: number, endIndex: number, richText: string, pasting?: boolean): void;
/**
* Returns true if an embedded font is available with the specified fontName and fontStyle
* where Font.fontType is flash.text.FontType.EMBEDDED. Starting with Flash Player 10,
* two kinds of embedded fonts can appear in a SWF file. Normal embedded fonts are only used with
* TextField objects.
* CFF embedded fonts are only used with the flash.text.engine classes. The two types are distinguished by the
* fontType property of the Font class, as returned by the enumerateFonts() function.
*
* TextField cannot use a font of type EMBEDDED_CFF. If embedFonts is set to true
* and the only font available at run time with the specified name and style is of type EMBEDDED_CFF,
* Flash Player fails to render the text, as if no embedded font were available with the specified name and style.
* If both EMBEDDED and EMBEDDED_CFF fonts are available with the same name and style, the EMBEDDED
* font is selected and text renders with the EMBEDDED font.
* @param fontName The name of the embedded font to check.
* @param fontStyle Specifies the font style to check. Use flash.text.FontStyle
* @return true if a compatible embedded font is available, otherwise false.
* @throws ArgumentError The fontStyle specified is not a member of flash.text.FontStyle.
*/
static isFontCompatible(fontName: string, fontStyle: string): boolean;
pasteRichText(richText: string): boolean;
/**
* Replaces the current selection with the contents of the value parameter.
* The text is inserted at the position of the current selection, using the current default character
* format and default paragraph format. The text is not treated as HTML.
*
* You can use the replaceSelectedText() method to insert and delete text without disrupting
* the character and paragraph formatting of the rest of the text.
* Note: This method does not work if a style sheet is applied to the text field.
* @param value The string to replace the currently selected text.
* @throws Error This method cannot be used on a text field with a style sheet.
*/
replaceSelectedText(value: string): void;
/**
* Replaces the range of characters that the beginIndex and
* endIndex parameters specify with the contents
* of the newText parameter. As designed, the text from
* beginIndex to endIndex-1 is replaced.
* Note: This method does not work if a style sheet is applied to the text field.
* @param beginIndex The zero-based index value for the start position of the replacement range.
* @param endIndex The zero-based index position of the first character after the desired
* text span.
* @param newText The text to use to replace the specified range of characters.
* @throws Error This method cannot be used on a text field with a style sheet.
*/
replaceText(beginIndex: number, endIndex: number, newText: string): void;
/**
* 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. If the two parameter values are the same,
* this method sets the insertion point, as if you set the
* caretIndex property.
* @param 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).
* @param endIndex The zero-based index value of the last character in the selection.
* @internal Need to add an example.
*/
setSelection(beginIndex: number, endIndex: number): void;
/**
* Applies the text formatting that the format parameter specifies to the specified text in a text field.
* The value of format must be a TextFormat object that specifies the
* desired text formatting changes. Only the non-null properties of format are applied
* to the text field. Any property of format that is set to null is not
* applied. By default, all of the properties of a newly created TextFormat object are set to null.
* Note: This method does not work if a style sheet is applied to the text field.
* The setTextFormat() method changes the text formatting applied to a range of
* characters or to the entire body of text in a text field.
* To apply the properties of format to all text in the text
* field, do not specify values for beginIndex and endIndex. To apply the
* properties of the format to a range of text, specify values for the beginIndex and
* the endIndex parameters. You can use the length property to determine
* the index values.The two types of formatting information in a TextFormat object are
* character level formatting and paragraph level formatting.
* Each character in a text field can have its own character formatting
* settings, such as font name, font size, bold, and italic.For paragraphs,
* the first character of the paragraph is examined for the paragraph formatting
* settings for the entire paragraph. Examples of paragraph formatting settings are left margin,
* right margin, and indentation.Any text inserted manually by the user, or replaced by the
* replaceSelectedText() method, receives the default text field formatting for new text,
* and not the formatting specified for the text insertion point. To set the default
* formatting for new text, use defaultTextFormat.
* @param format A TextFormat object that contains character and paragraph formatting information.
* @param beginIndex Optional; an integer that specifies the zero-based index position specifying the
* first character of the desired range of text.
* @param endIndex Optional; 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.
*
* UsageDescriptionmy_textField.setTextFormat(textFormat:TextFormat)
* Applies the properties of textFormat to all text in the text
* field.my_textField.setTextFormat(textFormat:TextFormat, beginIndex:int)
* Applies the properties of textFormat to the text starting with the
* beginIndex position.my_textField.setTextFormat(textFormat:TextFormat, beginIndex:int,
* endIndex:int)Applies the properties of the textFormat parameter to the span of
* text from the beginIndex position to the endIndex-1 position.
* Notice that any text inserted manually by the user, or replaced by the
* replaceSelectedText() method, receives the default text field formatting for new
* text, and not the formatting specified for the text insertion point. To set a text field's
* default formatting for new text, use the defaultTextFormat property.
* @throws Error This method cannot be used on a text field with a style sheet.
* @throws RangeError The beginIndex or endIndex specified is out of range.
*/
setTextFormat(format: TextFormat, beginIndex?: number, endIndex?: number): void;
}
//# sourceMappingURL=TextField.d.ts.map