Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RichText

Text UI element that can process simple BBCode style markdown to control text appearance. The same tags as in the in-game notes are supported:
[b]: Bold (does not work when the widget is set to a custom font using setFont)
[i]: Italic (does not work when the widget is set to a custom font using setFont)
[size=X]: Control the font size
[color=#RRGGBB]: Control the text color

Tags are closed using [/tag]. Here's an example of a text using tags:
You can use [color=#ff0000]colors[/color], [b]bold[/b] or [i]italic[/i] text, [size=9]different[/size] [size=16]sizes[/size], and [color=#00ff00][size=8][b][i]combine text styles.[/color][/size][/b][/i]

Hierarchy

Index

Methods

getAutoWrap

  • getAutoWrap(): boolean
  • Return whether the text is automatically wrapped.

    Returns boolean

getFontFileName

  • getFontFileName(): string

getFontPackageId

  • getFontPackageId(): string
  • Return the id of the package that contains the TrueType font file name used for the text. Empty if no custom font is used or no package is specified (and the package containing the script is used).

    Returns string

getFontSize

  • getFontSize(): number

getJustification

  • getJustification(): number

getOwningObject

getParent

  • getParent(): Widget | undefined
  • Return the widget that contains this widget, for example a border that wraps a check box. Returns undefined if this object has no parent.

    Returns Widget | undefined

getText

  • getText(): string
  • Return the currently displayed text.

    Returns string

getTextColor

isBold

  • isBold(): boolean

isEnabled

  • isEnabled(): boolean

isItalic

  • isItalic(): boolean

isVisible

  • isVisible(): boolean

setAutoWrap

  • setAutoWrap(autoWrap: boolean): RichText
  • Set whether the text is automatically wrapped. Auto-wrapping only works when the text has a fixed width, for example in a Canvas, LayoutBox, or in an UIElement with useWidgetSize set to false.

    Parameters

    • autoWrap: boolean

    Returns RichText

setBold

  • setBold(bold: boolean): this

setEnabled

  • setEnabled(enabled: boolean): this
  • Set whether the widget is enabled. When a widget is disabled, users can't interact with it and it is greyed out. When a widget that contains other widgets (like VerticalBox) is disabled, all its children behave as if disabled, too. By default, widgets are enabled.

    Parameters

    • enabled: boolean

      Whether to enable the widget.

    Returns this

setFont

  • setFont(fontFilename: string, packageId?: string): this
  • Set the TrueType font file used for the text. If a custom font is used, the bold and italic settings don't have an effect. Place your font files in the "Fonts" folder of your package.

    Parameters

    • fontFilename: string

      The filename of the TTF file to load. Set to empty string to use the standard font (and enable bold and italic settings).

    • Optional packageId: string

      The id of the package that contains the TTF file (in the Fonts folder). Can usually be empty when used from scripts to use the same package that contains the script file, but you need to explicitly pass refPackageId for the current package or a package id when you use it in a callback. You can find package ids in the manifest.json file in package folders. Usually you won't use this parameter, unless you have a specific reason to load a font from a different package than where the script is located.

    Returns this

setFontSize

  • setFontSize(size: number): this

setItalic

  • setItalic(italic: boolean): this

setJustification

  • setJustification(justification: number): RichText

setText

  • Set the displayed text. Can include "\n" to indicate new lines. Can include BBCode tags, see RichText for a list of supported tags.

    Parameters

    • text: string

      The new text

    Returns RichText

setTextColor

  • setTextColor(color: Color | [r: number, g: number, b: number, a: number]): this

setVisible

  • setVisible(visible: boolean): Widget
  • Set whether the widget is visible. When a widget that contains other widgets (like VerticalBox) is invisible, all its children are invisible, too. The layout of widgets is updated when visibility changes, and invisible widgets are treated as if they don't exist.

    Parameters

    • visible: boolean

      Whether the widget is visible.

    Returns Widget