RichTextLabel

Label that displays rich text.

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. Note: RichTextLabel doesn't support entangled BBCode tags. For example, instead of using $(B bold$(D i)bold italic)italic$(D /i), use $(B bold$(D i)bold italic$(D /i))$(I italic). Note: Unlike Label, RichTextLabel doesn't have a property to horizontally align text to the center. Instead, enable bbcodeEnabled and surround the text in a $(D center) tag as follows: $(D center)Example$(D /center). There is currently no built-in way to vertically align text either, but this can be emulated by relying on anchors/containers and the fitContentHeight property.

@GodotBaseClass
struct RichTextLabel {}

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Enums

Align
enum Align
Constants
enum Constants
ItemType
enum ItemType
ListType
enum ListType

Functions

_guiInput
void _guiInput(InputEvent arg0)
_scrollChanged
void _scrollChanged(double arg0)
addImage
void addImage(Texture image, long width, long height)

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
void addText(String text)

Adds raw non-BBCode-parsed text to the tag stack.

appendBbcode
GodotError appendBbcode(String bbcode)

Parses bbcode and adds tags to the tag stack as needed. Returns the result of the parsing, constant OK if successful. Note: Using this method, you can't close a tag that was opened in a previous appendBbcode call. This is done to improve performance, especially when updating large RichTextLabels since rebuilding the whole BBCode every time would be slower. If you absolutely need to close a tag in a future method call, append the bbcodeText instead of using appendBbcode.

clear
void clear()

Clears the tag stack and sets bbcodeText to an empty string.

getBbcode
String getBbcode()
getContentHeight
long getContentHeight()

Returns the height of the content.

getEffects
Array getEffects()
getLineCount
long getLineCount()

Returns the total number of newlines in the tag stack's text tags. Considers wrapped text as one line.

getPercentVisible
double getPercentVisible()
getTabSize
long getTabSize()
getText
String getText()
getTotalCharacterCount
long getTotalCharacterCount()

Returns the total number of characters from text tags. Does not include BBCodes.

getVScroll
VScrollBar getVScroll()

Returns the vertical scrollbar.

getVisibleCharacters
long getVisibleCharacters()
getVisibleLineCount
long getVisibleLineCount()

Returns the number of visible lines.

installEffect
void installEffect(VariantArg0 effect)

Installs a custom effect. effect should be a valid RichTextEffect.

isFitContentHeightEnabled
bool isFitContentHeightEnabled()
isMetaUnderlined
bool isMetaUnderlined()
isOverridingSelectedFontColor
bool isOverridingSelectedFontColor()
isScrollActive
bool isScrollActive()
isScrollFollowing
bool isScrollFollowing()
isSelectionEnabled
bool isSelectionEnabled()
isUsingBbcode
bool isUsingBbcode()
newline
void newline()

Adds a newline tag to the tag stack.

opAssign
typeof(null) opAssign(typeof(null) n)
opEquals
bool opEquals(RichTextLabel other)
opEquals
bool opEquals(typeof(null) n)
parseBbcode
GodotError parseBbcode(String bbcode)

The assignment version of appendBbcode. Clears the tag stack and inserts the new content. Returns constant OK if parses bbcode successfully.

parseExpressionsForValues
Dictionary parseExpressionsForValues(PoolStringArray expressions)

Parses BBCode parameter expressions into a dictionary.

pop
void pop()

Terminates the current tag. Use after push_* methods to close BBCodes manually. Does not need to follow add_* methods.

pushAlign
void pushAlign(long _align)

Adds an $(D align) tag based on the given align value. See _align for possible values.

pushBold
void pushBold()

Adds a $(D font) tag with a bold font to the tag stack. This is the same as adding a $(D b) tag if not currently in a $(D i) tag.

pushBoldItalics
void pushBoldItalics()

Adds a $(D font) tag with a bold italics font to the tag stack.

pushCell
void pushCell()

Adds a $(D cell) tag to the tag stack. Must be inside a $(D table) tag. See pushTable for details.

pushColor
void pushColor(Color color)

Adds a $(D color) tag to the tag stack.

pushFont
void pushFont(Font font)

Adds a $(D font) tag to the tag stack. Overrides default fonts for its duration.

pushIndent
void pushIndent(long level)

Adds an $(D indent) tag to the tag stack. Multiplies level by current tabSize to determine new margin length.

pushItalics
void pushItalics()

Adds a $(D font) tag with a italics font to the tag stack. This is the same as adding a $(D i) tag if not currently in a $(D b) tag.

pushList
void pushList(long type)

Adds a $(D list) tag to the tag stack. Similar to the BBCodes $(D ol) or $(D ul), but supports more list types. Not fully implemented!

pushMeta
void pushMeta(VariantArg0 data)

Adds a $(D meta) tag to the tag stack. Similar to the BBCode $(D url=something){text}$(D /url), but supports non-String metadata types.

pushMono
void pushMono()

Adds a $(D font) tag with a monospace font to the tag stack.

pushNormal
void pushNormal()

Adds a $(D font) tag with a normal font to the tag stack.

pushStrikethrough
void pushStrikethrough()

Adds a $(D s) tag to the tag stack.

pushTable
void pushTable(long columns)

Adds a $(D table=columns) tag to the tag stack.

pushUnderline
void pushUnderline()

Adds a $(D u) tag to the tag stack.

removeLine
bool removeLine(long line)

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 $(D 0, get_line_count() - 1).

scrollToLine
void scrollToLine(long line)

Scrolls the window's top line to match line.

setBbcode
void setBbcode(String text)
setEffects
void setEffects(Array effects)
setFitContentHeight
void setFitContentHeight(bool enabled)
setMetaUnderline
void setMetaUnderline(bool enable)
setOverrideSelectedFontColor
void setOverrideSelectedFontColor(bool _override)
setPercentVisible
void setPercentVisible(double percent_visible)
setScrollActive
void setScrollActive(bool active)
setScrollFollow
void setScrollFollow(bool follow)
setSelectionEnabled
void setSelectionEnabled(bool enabled)
setTabSize
void setTabSize(long spaces)
setTableColumnExpand
void setTableColumnExpand(long column, bool expand, long ratio)

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.

setText
void setText(String text)
setUseBbcode
void setUseBbcode(bool enable)
setVisibleCharacters
void setVisibleCharacters(long amount)
toHash
size_t toHash()

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Properties

bbcodeEnabled
bool bbcodeEnabled [@property getter]
bool bbcodeEnabled [@property setter]

If true, the label uses BBCode formatting. Note: Trying to alter the RichTextLabel's text with addText will reset this to false. Use instead appendBbcode to preserve BBCode formatting.

bbcodeText
String bbcodeText [@property getter]
String bbcodeText [@property setter]

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 the += 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, unless you absolutely need to close a tag that was opened in an earlier method call.

customEffects
Array customEffects [@property getter]
Array customEffects [@property setter]

The currently installed custom effects. This is an array of RichTextEffects. To add a custom effect, it's more convenient to use installEffect.

fitContentHeight
bool fitContentHeight [@property getter]
bool fitContentHeight [@property setter]

If true, the label's height will be automatically updated to fit its content. Note: This property is used as a workaround to fix issues with RichTextLabel in Containers, but it's unreliable in some cases and will be removed in future versions.

metaUnderlined
bool metaUnderlined [@property getter]
bool metaUnderlined [@property setter]

If true, the label underlines meta tags such as $(D url){text}$(D /url).

overrideSelectedFontColor
bool overrideSelectedFontColor [@property getter]
bool overrideSelectedFontColor [@property setter]

If true, the label uses the custom font color.

percentVisible
double percentVisible [@property getter]
double percentVisible [@property setter]

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
bool scrollActive [@property getter]
bool scrollActive [@property setter]

If true, the scrollbar is visible. Setting this to false does not block scrolling completely. See scrollToLine.

scrollFollowing
bool scrollFollowing [@property getter]
bool scrollFollowing [@property setter]

If true, the window scrolls down to display new content automatically.

selectionEnabled
bool selectionEnabled [@property getter]
bool selectionEnabled [@property setter]

If true, the label allows text selection.

tabSize
long tabSize [@property getter]
long tabSize [@property setter]

The number of spaces associated with a single tab length. Does not affect \t in text tags, only indent tags.

text
String text [@property getter]
String text [@property setter]

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
long visibleCharacters [@property getter]
long visibleCharacters [@property setter]

The restricted number of characters to display in the label. If -1, all characters will be displayed. Note: Setting this property updates percentVisible based on current getTotalCharacterCount.

Static functions

_new
RichTextLabel _new()

Construct a new instance of RichTextLabel. Note: use memnew!RichTextLabel instead.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

GDNativeClassBinding
struct GDNativeClassBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(ToRef) as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta