Color legend plain property dependency property method event
The full text element: read-only text with colored words, links and inline images, or an editable text field with a caret, selection, clipboard and undo. Text longer than the box scrolls inside it. Only the lines inside the visible area are drawn each frame, so the length of the text is limited by memory, not by the GPU texture size.
RichTextBox derives from BaseElement and has its members too. The text page shows it in context, with code and screenshots.
Names are colored by what they are: a plain property, a method, an event or a dependency property, which a style, a binding or an animation can set.
Properties
BackgroundStyle 🠆
ImageStyle · The style of the image the box draws behind its text.
CharacterPrintDelayMs 🠆
int · The time between two characters printed by AnimateText, in milliseconds. Negative values become 0; 0 sets the text at once.
EnterTypesLineBreak 🠆
bool · Whether Enter types a line break in a read-write box; Ctrl+Enter then ends the editing. Default false.
FontPath 🠆
string · The path of a TTF or OTF file to draw with (see Fonts). A path that loads replaces the font system in use; an empty or unreadable path goes back to the general font, but keeps a font system you set by hand (as a label does).
FontSize 🠆
float · The font size in units. Negative values become 0, and 0 draws nothing. Default DefaultSettings.DefaultFontSize (14).
FontSystem 🠆
FontSystem · Read-only. The font system in use: FontSystemOverride, or GeneralFontSystem without one.
FontSystemOverride 🠆
FontSystem · A FontStashSharp font system for this box only, used instead of the general one. Setting FontPath sets it too. The box does not dispose it.
Formatting 🠆
RichTextBoxFormatting · Whether a read-only box reads rich formatting tags out of its text. Default Plain.
GeneralFontSystem 🠆
FontSystem · Static. The same value as Label.GeneralFontSystem: the font system of every text element without one of its own.
GeneralMouseCursorsSet 🠆
MouseCursorsSet · Static. The cursors of every element of this style type; null (the default) falls back to DefaultMouseCursorsSet.
GeneralStyle 🠆
RichTextBoxStyle · Static. The style of every element of this style type. It starts as a copy of the framework defaults; changing one of its properties updates every such element, a property it leaves unset takes its default.
InputType 🠆
RichTextBoxInputType · Whether typing inserts or replaces the character at the caret. The Insert key switches it. Default Insert.
LastFontError 🠆
Exception · Read-only. The exception of the last failed font preparation (font system or font size not usable), null when the font is fine. The box shows no text and gives up the keyboard while it has no font.
LineSpacing 🠆
int · Extra space between two lines, in units. Negative values become 0.
MouseCursorsSet 🠆
MouseCursorsSet · Read-only. The cursors the element shows: its override, else the set given to the control it is a part of, else its type’s general set, else DefaultMouseCursorsSet.
MouseCursorsSetOverride 🠆
MouseCursorsSet · The cursors of this element only, passed on to its parts that have none of their own.
RichOutlineThickness 🠆
float · How far the outline of an [o=n] tag reaches around the letters, in units. Default 1.
ScrollBars 🠆
ScrollBars · Which scroll bars the box may show when its text is larger than the box. Default None.
ScrollBarsStyle 🠆
SliderStyle · The style of the scroll bars.
ScrollBarsThickness 🠆
int · The thickness of the scroll bars in units. Default 12 (DefaultSettings.DefaultScrollBarsThickness).
ScrollToEndDuringTextAnimation 🠆
bool · Whether AnimateText keeps the box scrolled to the end while it prints.
StyleOverride 🠆
RichTextBoxStyle · A style for this element only, applied over the general style. Setting it to null takes its values back out.
Text 🠆
string · The text shown. Line breaks become \n, tabs become spaces, then TextFilter is applied. Default "".
TextAlignment 🠆
TextAlignment · How each line is placed across the width. Justify widens the spaces of wrapped lines in a box with a width of its own. Default Left.
TextCursorColor 🠆
Color · The color of the caret. Default DefaultSettings.DefaultTextCursorColor (black).
TextCursorThickness 🠆
int · The width of the caret bar, or the height of the overwrite underline, in units. Default DefaultSettings.DefaultTextCursorThickness (1).
TextFilter 🠆
Func<string, string> · Transforms every text assigned to Text, edits included. Setting it filters the current text.
TextMargin 🠆
Margin · The space between the box’s edges and its text, in units.
TextSelectionColor 🠆
Color · The color behind selected text. Default DefaultSettings.DefaultTextSelectionColor (light blue).
Type 🠆
RichTextBoxType · Whether the text can be edited. Default ReadOnly.
VerticalTextAlignment 🠆
VerticalTextAlignment · Where the lines sit in a box taller than its text. Applies only while the text fits; a scrolling text starts at the top. Default Top.
WrapType 🠆
TextWrap · Whether lines break to fit the width (with a fixed or stretched width, or a MaxWidth). Words wider than a line are broken. Default NoWrap.
Fields
RichActions 🠆
List<Action> · Static field. The actions [a=n] links run, shared by every box.
RichColors 🠆
List<Color> · Static field. The colors [c=n] tags index, shared by every box.
RichFonts 🠆
List<string> · Static field. The font files [f=n] tags draw in, shared by every box (each loaded once).
RichImages 🠆
List<Texture2D> · Static field. The textures [i=n] tags show, shared by every box.
Methods
RichTextBox() 🠆
RichTextBox(string name = null) · Creates a rich text box. The name is used by GetElementByName.
| Parameter | Type | Description |
|---|---|---|
name |
string |
The element’s Name, which GetElementByName finds it by. Default: null. |
AnimateText() 🠆
AnimateText(string text) · Types the text out with CharacterPrintDelayMs per character and makes the box read-only. Stops a running animation first.
| Parameter | Type | Description |
|---|---|---|
text |
string |
The text to type out; it becomes the box’s text. |
PlaceCursorAt() 🠆
PlaceCursorAt(int position) · Moves the caret to a text position (clamped to the text), scrolls it into view and gives the box the keyboard. A read-only box shows no caret but scrolls there.
| Parameter | Type | Description |
|---|---|---|
position |
int |
The text position: the number of characters before the caret. |
PlaceCursorAtTextEnd() 🠆
PlaceCursorAtTextEnd() · PlaceCursorAt(Text.Length).
PlaceCursorAtTextStart() 🠆
PlaceCursorAtTextStart() · PlaceCursorAt(0).
SelectAllText() 🠆
SelectAllText() · Selects the whole text, scrolls to its end and gives the box the keyboard.
SelectTextInterval() 🠆
SelectTextInterval(int start, int end) · Selects the text between two positions (clamped to the text), with the caret at end, scrolled into view, and gives the box the keyboard. Does nothing when start equals end.
| Parameter | Type | Description |
|---|---|---|
start |
int |
The text position where the selection starts. |
end |
int |
The text position where the selection ends, where the caret goes. |
StopTextAnimation() 🠆
StopTextAnimation() · Stops a running text animation; the whole text is shown then.
Events
OnApply 🠆
(BaseElement sender, string text) · A read-write box ends its editing: Enter (Ctrl+Enter with EnterTypesLineBreak), a press elsewhere or another element focused. Not when it is hidden, disabled or removed. Raised even if the text did not change.
| Parameter | Type | Description |
|---|---|---|
sender |
BaseElement |
The element that raised the event. |
text |
string |
The box’s text. |
OnTextChanged 🠆
(BaseElement sender, string text) · Text changed, by typing, deleting, pasting, undo or redo, code, a binding, a style or the end of a text animation. The new lines are already laid out.
| Parameter | Type | Description |
|---|---|---|
sender |
BaseElement |
The element that raised the event. |
text |
string |
The new text. |