Label that displays rich text.
    public class RichTextLabel : Control

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(string) and the push_* / Pop() methods.

Inheritance Chain

Constructors

    public RichTextLabel()

Signals

    "meta_clicked" (Nil meta)

Triggered when the user clicks on content between [url] tags. If the meta is defined in text, e.g. [url={"data"="hi"}]hi[/url], then the parameter for this signal will be a String type. If a particular type or an object is desired, the PushMeta(object) method must be used to manually insert the data into the tag stack.

    "meta_hover_ended" (Nil meta)

Triggers when the mouse exits a meta tag.

    "meta_hover_started" (Nil meta)

Triggers when the mouse enters a meta tag.

Properties

    public bool BbcodeEnabled { get; set; }

If true, the label uses BBCode formatting.

    public string BbcodeText { get; set; }

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.

    public Collections.Array CustomEffects { get; set; }

    public bool MetaUnderlined { get; set; }

If true, the label underlines meta tags such as <u>{text}</u>.

    public bool OverrideSelectedFontColor { get; set; }

If true, the label uses the custom font color.

    public float PercentVisible { get; set; }

The text’s visibility, as a [float](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/float] between 0.0 and 1.0.

    public bool ScrollActive { get; set; }

If true, the scrollbar is visible. Does not block scrolling completely. See ScrollToLine(int).

    public bool ScrollFollowing { get; set; }

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

    public bool SelectionEnabled { get; set; }

If true, the label allows text selection.

    public int TabSize { get; set; }

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

    public string Text { get; set; }

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.

    public int VisibleCharacters { get; set; }

The restricted number of characters to display in the label. If -1, all characters will be displayed.

Methods

    public void AddImage(Texture image)

Adds an image’s opening and closing tags to the tag stack.

    public void AddText(string text)

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

    public Error AppendBbcode(string bbcode)

Parses bbcode and adds tags to the tag stack as needed. Returns the result of the parsing, [constant OK] if successful.

    public void Clear()

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

    [Obsolete("GetBbcode is deprecated. Use the BbcodeText property instead.")]
    public string GetBbcode()

Getter for BbcodeText

    public int GetContentHeight()

Returns the height of the content.

    [Obsolete("GetEffects is deprecated. Use the CustomEffects property instead.")]
    public Godot.Collections.Array GetEffects()

Getter for CustomEffects

    public int GetLineCount()

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

    [Obsolete("GetPercentVisible is deprecated. Use the PercentVisible property instead.")]
    public float GetPercentVisible()

Getter for PercentVisible

    [Obsolete("GetTabSize is deprecated. Use the TabSize property instead.")]
    public int GetTabSize()

Getter for TabSize

    [Obsolete("GetText is deprecated. Use the Text property instead.")]
    public string GetText()

Getter for ItemType.Text

    public int GetTotalCharacterCount()

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

    [Obsolete("GetVisibleCharacters is deprecated. Use the VisibleCharacters property instead.")]
    public int GetVisibleCharacters()

Getter for VisibleCharacters

    public int GetVisibleLineCount()

Returns the number of visible lines.

    public VScrollBar GetVScroll()

Returns the vertical scrollbar.

    public void InstallEffect(object effect)

    [Obsolete("IsMetaUnderlined is deprecated. Use the MetaUnderlined property instead.")]
    public bool IsMetaUnderlined()

Getter for MetaUnderlined

    [Obsolete("IsOverridingSelectedFontColor is deprecated. Use the OverrideSelectedFontColor property instead.")]
    public bool IsOverridingSelectedFontColor()

Getter for OverrideSelectedFontColor

    [Obsolete("IsScrollActive is deprecated. Use the ScrollActive property instead.")]
    public bool IsScrollActive()

Getter for ScrollActive

    [Obsolete("IsScrollFollowing is deprecated. Use the ScrollFollowing property instead.")]
    public bool IsScrollFollowing()

Getter for ScrollFollowing

    [Obsolete("IsSelectionEnabled is deprecated. Use the SelectionEnabled property instead.")]
    public bool IsSelectionEnabled()

Getter for SelectionEnabled

    [Obsolete("IsUsingBbcode is deprecated. Use the BbcodeEnabled property instead.")]
    public bool IsUsingBbcode()

Getter for BbcodeEnabled

    public void Newline()

Adds a newline tag to the tag stack.

    public Error ParseBbcode(string bbcode)

The assignment version of AppendBbcode(string). Clears the tag stack and inserts the new content. Returns [constant OK] if parses bbcode successfully.

    public Dictionary ParseExpressionsForValues(string[] expressions)

    public void Pop()

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

    public void PushAlign(Align align)

Adds an align tag based on the given align value. See Align for possible values.

    public void PushCell()

Adds a [cell] tag to the tag stack. Must be inside a [table] tag. See PushTable(int) for details.

    public void PushColor(Color color)

Adds a color tag to the tag stack.

    public void PushFont(Font font)

Adds a font tag to the tag stack. Overrides default fonts for its duration.

    public void PushIndent(int level)

Adds an [indent] tag to the tag stack. Multiplies “level” by current tab_size to determine new margin length.

    public void PushList(ListType type)

Adds a [list] tag to the tag stack. Similar to the BBCodes [ol] or [ul], but supports more list types. Not fully implemented!

    public void PushMeta(object data)

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

    public void PushStrikethrough()

Adds a [s] tag to the tag stack.

    public void PushTable(int columns)

Adds a [table=columns] tag to the tag stack.

    public void PushUnderline()

Adds a [u] tag to the tag stack.

    public bool RemoveLine(int line)

Removes a line of content from the label. Returns true if the line exists.

    public void ScrollToLine(int line)

Scrolls the window’s top line to match line.

    [Obsolete("SetBbcode is deprecated. Use the BbcodeText property instead.")]
    public void SetBbcode(string text)

Setter for BbcodeText

    [Obsolete("SetEffects is deprecated. Use the CustomEffects property instead.")]
    public void SetEffects(Godot.Collections.Array effects)

Setter for CustomEffects

    [Obsolete("SetMetaUnderline is deprecated. Use the MetaUnderlined property instead.")]
    public void SetMetaUnderline(bool enable)

Setter for MetaUnderlined

    [Obsolete("SetOverrideSelectedFontColor is deprecated. Use the OverrideSelectedFontColor property instead.")]
    public void SetOverrideSelectedFontColor(bool @override)

Setter for OverrideSelectedFontColor

    [Obsolete("SetPercentVisible is deprecated. Use the PercentVisible property instead.")]
    public void SetPercentVisible(float percentVisible)

Setter for PercentVisible

    [Obsolete("SetScrollActive is deprecated. Use the ScrollActive property instead.")]
    public void SetScrollActive(bool active)

Setter for ScrollActive

    [Obsolete("SetScrollFollow is deprecated. Use the ScrollFollowing property instead.")]
    public void SetScrollFollow(bool follow)

Setter for ScrollFollowing

    [Obsolete("SetSelectionEnabled is deprecated. Use the SelectionEnabled property instead.")]
    public void SetSelectionEnabled(bool enabled)

Setter for SelectionEnabled

    public void SetTableColumnExpand(int column, bool expand, int 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.

    [Obsolete("SetTabSize is deprecated. Use the TabSize property instead.")]
    public void SetTabSize(int spaces)

Setter for TabSize

    [Obsolete("SetText is deprecated. Use the Text property instead.")]
    public void SetText(string text)

Setter for ItemType.Text

    [Obsolete("SetUseBbcode is deprecated. Use the BbcodeEnabled property instead.")]
    public void SetUseBbcode(bool enable)

Setter for BbcodeEnabled

    [Obsolete("SetVisibleCharacters is deprecated. Use the VisibleCharacters property instead.")]
    public void SetVisibleCharacters(int amount)

Setter for VisibleCharacters

Inner Types

Align

Name Value Description
Left 0  
Center 1  
Right 2  
Fill 3  

ItemType

Name Value Description
Frame 0  
Text 1  
Image 2  
Newline 3  
Font 4  
Color 5  
Underline 6  
Strikethrough 7  
Align 8  
Indent 9  
List 10  
Table 11  
Fade 12  
Shake 13  
Wave 14  
Tornado 15  
Rainbow 16  
Customfx 18  
Meta 17  

ListType

Name Value Description
Numbers 0  
Letters 1  
Dots 2  
Tags: