Struct RichTextLabel
Label that displays rich text.
struct RichTextLabel
;
Rich text can contain custom text, fonts, images and some basic formatting. The label manages these as an internal tag stack. It also adapts itself to given width/heights.
Note: Assignments to bbcodeText
clear the tag stack and reconstruct it from the property's contents. Any edits made to bbcodeText
will erase previous edits made from other manual sources such as appendBbcode
and the push_*
/ pop
methods.
Properties
Name | Type | Description |
---|---|---|
bbcodeEnabled [get, set]
|
bool | If true , the label uses BBCode formatting.
|
bbcodeText [get, set]
|
String | The label's text in BBCode format. Is not representative of manual modifications to the internal tag stack. Erases changes made by other methods when edited.
Note: It is unadvised to use += operator with bbcode_text (e.g. bbcode_text += "some string" ) as it replaces the whole text and can cause slowdowns. Use appendBbcode for adding text instead.
|
customEffects [get, set]
|
Array | The currently installed custom effects. This is an array of RichTextEffect s.
To add a custom effect, it's more convenient to use installEffect .
|
metaUnderlined [get, set]
|
bool | If true , the label underlines meta tags such as class="pln">D url{text}class="pln">D /url .
|
overrideSelectedFontColor [get, set]
|
bool | If true , the label uses the custom font color.
|
percentVisible [get, set]
|
double | The range of characters to display, as a double between 0.0 and 1.0. When assigned an out of range value, it's the same as assigning 1.0.
Note: Setting this property updates visibleCharacters based on current getTotalCharacterCount .
|
scrollActive [get, set]
|
bool | If true , the scrollbar is visible. Setting this to false does not block scrolling completely. See scrollToLine .
|
scrollFollowing [get, set]
|
bool | If true , the window scrolls down to display new content automatically.
|
selectionEnabled [get, set]
|
bool | If true , the label allows text selection.
|
tabSize [get, set]
|
long | The number of spaces associated with a single tab length. Does not affect \t in text tags, only indent tags.
|
text [get, set]
|
String | The raw text of the label.
When set, clears the tag stack and adds a raw text tag to the top of it. Does not parse BBCodes. Does not modify bbcodeText .
|
visibleCharacters [get, set]
|
long | The restricted number of characters to display in the label. If -1 , all characters will be displayed.
|
Methods
Name | Description |
---|---|
_guiInput
|
|
_scrollChanged
|
|
addImage
|
Adds an image's opening and closing tags to the tag stack, optionally providing a width and height to resize the image.
If width or height is set to 0, the image size will be adjusted in order to keep the original aspect ratio.
|
addText
|
Adds raw non-BBCode-parsed text to the tag stack. |
appendBbcode
|
Parses bbcode and adds tags to the tag stack as needed. Returns the result of the parsing, constant OK if successful.
|
clear
|
Clears the tag stack and sets bbcodeText to an empty string.
|
getBbcode
|
|
getContentHeight
|
Returns the height of the content. |
getEffects
|
|
getLineCount
|
Returns the total number of newlines in the tag stack's text tags. Considers wrapped text as one line. |
getPercentVisible
|
|
getTabSize
|
|
getText
|
|
getTotalCharacterCount
|
Returns the total number of characters from text tags. Does not include BBCodes. |
getVisibleCharacters
|
|
getVisibleLineCount
|
Returns the number of visible lines. |
getVScroll
|
Returns the vertical scrollbar. |
installEffect
|
Installs a custom effect. effect should be a valid RichTextEffect .
|
isMetaUnderlined
|
|
isOverridingSelectedFontColor
|
|
isScrollActive
|
|
isScrollFollowing
|
|
isSelectionEnabled
|
|
isUsingBbcode
|
|
newline
|
Adds a newline tag to the tag stack. |
parseBbcode
|
The assignment version of appendBbcode . Clears the tag stack and inserts the new content. Returns constant OK if parses bbcode successfully.
|
parseExpressionsForValues
|
Parses BBCode parameter expressions into a dictionary.
|
pop
|
Terminates the current tag. Use after push_* methods to close BBCodes manually. Does not need to follow add_* methods.
|
pushAlign
|
Adds an class="pln">D align tag based on the given align value. See align for possible values.
|
pushBold
|
Adds a class="pln">D font tag with a bold font to the tag stack. This is the same as adding a class="pln">D b tag if not currently in a class="pln">D i tag.
|
pushBoldItalics
|
Adds a class="pln">D font tag with a bold italics font to the tag stack.
|
pushCell
|
Adds a class="pln">D cell tag to the tag stack. Must be inside a class="pln">D table tag. See pushTable for details.
|
pushColor
|
Adds a class="pln">D color tag to the tag stack.
|
pushFont
|
Adds a class="pln">D font tag to the tag stack. Overrides default fonts for its duration.
|
pushIndent
|
Adds an class="pln">D indent tag to the tag stack. Multiplies level by current tabSize to determine new margin length.
|
pushItalics
|
Adds a class="pln">D font tag with a italics font to the tag stack. This is the same as adding a class="pln">D i tag if not currently in a class="pln">D b tag.
|
pushList
|
Adds a class="pln">D list tag to the tag stack. Similar to the BBCodes class="pln">D ol or class="pln">D ul , but supports more list types. Not fully implemented!
|
pushMeta
|
Adds a class="pln">D meta tag to the tag stack. Similar to the BBCode class="pln">D url=something{text}class="pln">D /url , but supports non-String metadata types.
|
pushMono
|
Adds a class="pln">D font tag with a monospace font to the tag stack.
|
pushNormal
|
Adds a class="pln">D font tag with a normal font to the tag stack.
|
pushStrikethrough
|
Adds a class="pln">D s tag to the tag stack.
|
pushTable
|
Adds a class="pln">D table=columns tag to the tag stack.
|
pushUnderline
|
Adds a class="pln">D u tag to the tag stack.
|
removeLine
|
Removes a line of content from the label. Returns true if the line exists.
The line argument is the index of the line to remove, it can take values in the interval class="pln">D 0, get_line_count() - 1 .
|
scrollToLine
|
Scrolls the window's top line to match line .
|
setBbcode
|
|
setEffects
|
|
setMetaUnderline
|
|
setOverrideSelectedFontColor
|
|
setPercentVisible
|
|
setScrollActive
|
|
setScrollFollow
|
|
setSelectionEnabled
|
|
setTableColumnExpand
|
Edits the selected column's expansion options. If expand is true , the column expands in proportion to its expansion ratio versus the other columns' ratios.
For example, 2 columns with ratios 3 and 4 plus 70 pixels in available width would expand 30 and 40 pixels, respectively.
If expand is false , the column will not contribute to the total ratio.
|
setTabSize
|
|
setText
|
|
setUseBbcode
|
|
setVisibleCharacters
|
Enums
Name | Description |
---|---|
Align
|
|
Constants
|
|
ItemType
|
|
ListType
|