styledText | ||||||||||
Type | property | |||||||||
Dictionary | LCS | |||||||||
Library | LiveCode Script | |||||||||
Syntax |
| |||||||||
Associations | field | |||||||||
Summary | Specifies the contents of a field, with its text formatting represented as LiveCode styled text array. | |||||||||
Introduced | 5.5 | |||||||||
Changes | Support for the tabAlign paragraph style was added in version 8.1.2 | |||||||||
OS | mac, windows, linux, ios, android | |||||||||
Platforms | desktop, server, mobile | |||||||||
Parameters |
| |||||||||
Example |
| |||||||||
Values |
| |||||||||
Related | Property: HTMLText, textSize, flagged, textShift, metadata, textFont, RTFText, textStyle | |||||||||
Description | Use the styledText property to access and programatically manipulate the styled contents of a field. The styledText property is similar to rtfText and htmlText in that it provides a script-processable representation of the field's styled content. It differs from these two formats in two ways: 1) It is a fully faithful representation (set the styledText of field to the styledText of field results in no change to the field). 2) It is array-based. The styledText property returns a numerically-indexed array of paragraphs, each index representing each paragraph in the field in order: tStyledTextArray[1] = <first paragraph array> ... tStyledTextArray[<n>] = <last paragraph array> Each paragraph array has up to two keys:
The style array contains the values for each of the paragraph styles set on that paragraph. The list of styles that are supported are: textAlign, listStyle, listDepth, listIndent, firstIndent, leftIndent, rightIndent, spaceAbove, spaceBelow, tabStops, tabAlign, backgroundColor, borderWidth, borderColor, hGrid, vGrid, dontWrap, padding and hidden. The paragraph content array is a numerically-indexed array of runs, each index representing each run in the paragraph in order: tParagraphContentArray[1] = <first paragraph run array> ... tParagraphContentArray[<n>] = <last paragraph run array> Each paragraph run array has up to three keys:
The style array contains the values for each of the characters styles set on that run. The list of styles that are supported are: textFont, textSize, textStyle, textShift, textColor, backgroundColor, linkText, imageSource. If a run has Unicode text in it then the run array has a "unicodeText" key containing its content encoded as UTF-16. Otherwise, the run array has a "text" key containing its content encoded in the native text encoding. For example, take the following content consisting of two paragraphs: Centered Hello World Left-aligned Hello unicodeString This would transpire as the following array:
[ For brevity, single element arrays are represented using { ... } notation ] When setting the styledText property, the engine uses a very permissive algorithm to parse the arrays as follows:
| |||||||||
Tags | text processing |