Class RichTextLabel
- Namespace
- Forma
- Assembly
- Forma.dll
Lightweight BBCode label with styled text runs. It intentionally concentrates on the common
authoring tags (b, i, u, s/strike, color, and br) while preserving the retained
Control model and plain-text Text projection.
[TemplatePart("PART_RichTextPresenter", typeof(Container), true)]
public class RichTextLabel : TemplatedControl, IAddChild<Control>, IAddChild, INotifyPropertyChanged, IDisposable
- Inheritance
-
RichTextLabel
- Implements
- Derived
- Inherited Members
Constructors
RichTextLabel()
public RichTextLabel()
Fields
RichTextPresenterPartName
public const string RichTextPresenterPartName = "PART_RichTextPresenter"
Field Value
Properties
AccessibilityName
public override string AccessibilityName { get; }
Property Value
AccessibilityRole
public override AccessibilityRole AccessibilityRole { get; }
Property Value
Autowrap
public bool Autowrap { get; set; }
Property Value
AutowrapMode
public LabelAutowrapMode AutowrapMode { get; set; }
Property Value
BbcodeEnabled
public bool BbcodeEnabled { get; set; }
Property Value
ContextMenuEnabled
Enables the retained Copy/Select All context menu, matching Godot's context_menu_enabled.
public bool ContextMenuEnabled { get; set; }
Property Value
DeselectOnFocusLossEnabled
Whether selection is cleared when keyboard focus moves to another control, matching Godot's deselect_on_focus_loss_enabled.
public bool DeselectOnFocusLossEnabled { get; set; }
Property Value
DragAndDropSelectionEnabled
Whether pressing inside an existing selection can provide its text through the Control drag/drop lifecycle.
public bool DragAndDropSelectionEnabled { get; set; }
Property Value
FitContent
public bool FitContent { get; set; }
Property Value
Font
public SpriteFont Font { get; set; }
Property Value
- SpriteFont
FontColor
public Color? FontColor { get; set; }
Property Value
- Color?
HasSelection
Whether this label currently owns a non-empty selection.
public bool HasSelection { get; }
Property Value
HorizontalAlignment
public HorizontalAlignment HorizontalAlignment { get; set; }
Property Value
IsVerticalScrollBarVisible
Whether the retained vertical scrollbar is currently presented for overflowing, active document content.
public bool IsVerticalScrollBarVisible { get; }
Property Value
LetterSpacing
public float LetterSpacing { get; set; }
Property Value
MetaColor
Color used for metadata links when the span has no explicit foreground color.
public Color MetaColor { get; set; }
Property Value
- Color
MetaRegions
Current deterministic hit regions for spans carrying metadata.
public IReadOnlyList<RichTextMetaRegion> MetaRegions { get; }
Property Value
MetaUnderline
Whether metadata spans use the conventional Godot link underline.
public bool MetaUnderline { get; set; }
Property Value
MultiClickTimeout
Maximum interval between text clicks that belong to the same double/triple-click gesture.
public TimeSpan MultiClickTimeout { get; set; }
Property Value
MultiClickTolerance
Maximum pointer displacement between text clicks that belong to the same double/triple-click gesture.
public int MultiClickTolerance { get; set; }
Property Value
Padding
public Thickness Padding { get; set; }
Property Value
ScrollActive
Enables wheel scrolling and the retained scroll viewport, matching Godot's scroll_active.
public bool ScrollActive { get; set; }
Property Value
ScrollFollowing
Automatically follows newly appended content to its end, matching Godot's scroll_following.
public bool ScrollFollowing { get; set; }
Property Value
ScrollOffset
Current vertical document offset in pixels, clamped to the retained content range.
public int ScrollOffset { get; set; }
Property Value
ScrollStep
Pixels moved for one wheel notch. The default uses the document line height.
public int ScrollStep { get; set; }
Property Value
SelectionAutoScrollEnabled
Enables scrolling a document while a captured text-selection gesture is held beyond its vertical viewport.
public bool SelectionAutoScrollEnabled { get; set; }
Property Value
SelectionAutoScrollSpeed
Base selection auto-scroll velocity in pixels per second. Godot's 2-pixel 50 ms timer step corresponds to 40.
public float SelectionAutoScrollSpeed { get; set; }
Property Value
SelectionColor
Theme-like background color drawn behind selected document characters.
public Color SelectionColor { get; set; }
Property Value
- Color
SelectionEnabled
Enables Godot-style text selection for this read-only document.
public bool SelectionEnabled { get; set; }
Property Value
ShortcutKeysEnabled
Enables focused select-all and copy shortcuts, matching Godot's shortcut_keys_enabled.
public bool ShortcutKeysEnabled { get; set; }
Property Value
Spans
public IReadOnlyList<RichTextSpan> Spans { get; }
Property Value
TableCellWidth
Fallback width for one rendered RichText table cell when no full shaping/layout engine is installed.
public int TableCellWidth { get; set; }
Property Value
Text
public string Text { get; set; }
Property Value
TextDirection
public TextDirection TextDirection { get; set; }
Property Value
UIFont
public UIFont UIFont { get; set; }
Property Value
VerticalAlignment
public VerticalAlignment VerticalAlignment { get; set; }
Property Value
Methods
AddHorizontalRule(int, int, Color?, HorizontalAlignment, bool, bool)
Adds a Godot-style horizontal rule paragraph. Percentage dimensions use the content width.
public void AddHorizontalRule(int width = 90, int height = 2, Color? color = null, HorizontalAlignment alignment = HorizontalAlignment.Center, bool widthInPercent = true, bool heightInPercent = false)
Parameters
widthintheightintcolorColor?alignmentHorizontalAlignmentwidthInPercentboolheightInPercentbool
AddImage(Texture2D, float, float, Color?, object, string)
Adds an inline image, corresponding to Godot's add_image() API.
public void AddImage(Texture2D image, float width = 0, float height = 0, Color? modulate = null, object metadata = null, string altText = "")
Parameters
AppendBbcode(string)
public virtual void AppendBbcode(string bbcode)
Parameters
bbcodestring
AppendText(string)
public void AppendText(string text)
Parameters
textstring
ArrangeChildren()
protected override void ArrangeChildren()
Clear()
public void Clear()
Deselect()
Clears the current selection, matching Godot's deselect().
public void Deselect()
GetAutowrapMode()
public LabelAutowrapMode GetAutowrapMode()
Returns
GetContentHeight()
Returns the document's retained content height in pixels.
public int GetContentHeight()
Returns
GetContentWidth()
Returns the widest retained visual-line width in pixels.
public int GetContentWidth()
Returns
GetCurrentTableColumn()
public int GetCurrentTableColumn()
Returns
GetDragData(Point)
Returns the selected text when a retained drag begins from an existing selection.
public override object GetDragData(Point position)
Parameters
positionPoint
Returns
GetLineCount()
Returns the document's retained visual line count. Explicit and automatic wrapped lines are included.
public int GetLineCount()
Returns
GetLineHeight(int)
Returns the retained height of a visual line, or zero for an invalid line.
public int GetLineHeight(int line)
Parameters
lineint
Returns
GetLineOffset(int)
Returns the content-space offset of a visual line, or zero for an invalid line.
public float GetLineOffset(int line)
Parameters
lineint
Returns
GetLineRange(int)
Returns the retained plain-text range covered by a visual line, using Microsoft.Xna.Framework.Point.X for the inclusive start and Microsoft.Xna.Framework.Point.Y for the exclusive end.
public Point GetLineRange(int line)
Parameters
lineint
Returns
- Point
GetLineWidth(int)
Returns the retained width of a visual line, or zero for an invalid line.
public int GetLineWidth(int line)
Parameters
lineint
Returns
GetMenu()
Returns the retained context popup, equivalent to Godot's get_menu().
public PopupMenu GetMenu()
Returns
GetMetaUnderPosition(Point)
Returns metadata at the given screen-space position, equivalent to Godot's get_meta_under_mouse().
public object GetMetaUnderPosition(Point position)
Parameters
positionPoint
Returns
GetMinimumSize()
public override Vector2 GetMinimumSize()
Returns
- Vector2
GetParagraphCount()
Returns the number of explicit newline-delimited document paragraphs.
public int GetParagraphCount()
Returns
GetParagraphOffset(int)
Returns the content-space offset of an explicit paragraph, or zero for an invalid paragraph.
public float GetParagraphOffset(int paragraph)
Parameters
paragraphint
Returns
GetScrollMaximum()
Returns the maximum available vertical offset for the current bounds.
public int GetScrollMaximum()
Returns
GetScrollOffset()
public int GetScrollOffset()
Returns
GetSelectedText()
Returns the selected plain-text projection, matching Godot's get_selected_text().
public string GetSelectedText()
Returns
GetSelectionFrom()
Zero-based inclusive selection start, or -1 when no selection is active.
public int GetSelectionFrom()
Returns
GetSelectionLineOffset()
Returns the retained visual-line offset of the selection start, or -1 when there is no selection.
public float GetSelectionLineOffset()
Returns
GetSelectionTo()
Zero-based exclusive selection end, or -1 when no selection is active.
public int GetSelectionTo()
Returns
GetText()
public string GetText()
Returns
GetVScrollBar()
Returns the retained vertical scrollbar, corresponding to Godot's get_v_scroll_bar().
public VScrollBar GetVScrollBar()
Returns
GetVisibleContentRect()
Returns the screen-space clipped content viewport, corresponding to Godot's get_visible_content_rect().
public Rectangle GetVisibleContentRect()
Returns
- Rectangle
GetVisibleLineCount()
Returns the number of visual lines intersecting the clipped document viewport.
public int GetVisibleLineCount()
Returns
GetVisibleParagraphCount()
Returns the number of explicit paragraphs intersecting the clipped document viewport.
public int GetVisibleParagraphCount()
Returns
IsDeselectOnFocusLossEnabled()
public bool IsDeselectOnFocusLossEnabled()
Returns
IsDragAndDropSelectionEnabled()
public bool IsDragAndDropSelectionEnabled()
Returns
IsScrollActive()
public bool IsScrollActive()
Returns
IsScrollFollowing()
public bool IsScrollFollowing()
Returns
ParseBbcode(string)
public void ParseBbcode(string bbcode)
Parameters
bbcodestring
Pop()
public void Pop()
PushBgColor(Color)
public void PushBgColor(Color color)
Parameters
colorColor
PushBold()
public void PushBold()
PushCell()
Starts the next cell in the active table, matching Godot's push_cell().
public void PushCell()
PushColor(Color)
public void PushColor(Color color)
Parameters
colorColor
PushIndent(int)
Starts an indented rich-text block. Call Pop() after appending its content.
public void PushIndent(int level = 1)
Parameters
levelint
PushItalics()
public void PushItalics()
PushList(int, RichTextListType, bool, string)
Starts a list item with a Godot-style marker. Call Pop() after appending its content.
public void PushList(int level = 1, RichTextListType type = RichTextListType.Dots, bool capitalize = false, string bullet = "•")
Parameters
levelinttypeRichTextListTypecapitalizeboolbulletstring
PushMeta(object)
Starts a Godot-style clickable metadata span. Call Pop() after appending its text.
public void PushMeta(object meta)
Parameters
metaobject
PushStrikethrough()
public void PushStrikethrough()
PushTable(int, string)
Starts a Godot-style table. Call PushCell() for each cell and Pop() to close the table.
public void PushTable(int columns, string name = "")
Parameters
PushUnderline()
public void PushUnderline()
ScrollToLine(int)
Scrolls the requested zero-based visual line to the top of the retained viewport.
public void ScrollToLine(int line)
Parameters
lineint
ScrollToParagraph(int)
Scrolls the requested zero-based explicit paragraph to the top of the retained viewport.
public void ScrollToParagraph(int paragraph)
Parameters
paragraphint
ScrollToSelection()
Scrolls the visual line containing the selection start to the top of the document viewport.
public void ScrollToSelection()
Search(string, bool, bool)
Finds case-insensitive plain-text content, selects the match, and reveals its visual line; optionally continues from the active selection or searches backward.
public bool Search(string text, bool fromSelection = false, bool searchPrevious = false)
Parameters
Returns
Select(int, int)
Sets a normalized plain-text selection. This retained-layer convenience is intended for selection gestures.
public void Select(int from, int to)
Parameters
SelectAll()
Selects the complete plain-text document when SelectionEnabled is enabled.
public void SelectAll()
SetAutowrapMode(LabelAutowrapMode)
public void SetAutowrapMode(LabelAutowrapMode mode)
Parameters
modeLabelAutowrapMode
SetDeselectOnFocusLossEnabled(bool)
public void SetDeselectOnFocusLossEnabled(bool enabled)
Parameters
enabledbool
SetDragAndDropSelectionEnabled(bool)
public void SetDragAndDropSelectionEnabled(bool enabled)
Parameters
enabledbool
SetScrollActive(bool)
public void SetScrollActive(bool active)
Parameters
activebool
SetScrollFollow(bool)
public void SetScrollFollow(bool following)
Parameters
followingbool
SetScrollOffset(int)
public void SetScrollOffset(int offset)
Parameters
offsetint
SetText(string)
public void SetText(string text)
Parameters
textstring
Events
CopyRequested
Raised after a copy command submits text to Clipboard.
public event Action<RichTextLabel, string> CopyRequested
Event Type
MetaClicked
public event Action<RichTextLabel, object> MetaClicked