Api Sandbox UI Label
class

Label

public class Label : Panel

A generic text label. Can be made editable.

Constructors

Label()
Label(String text, String classname)

Properties

Name Type Description
HasContent virtual Boolean
ShouldDrawSelection Boolean
Selectable Boolean Can be selected
Tokenize Boolean If true and the text starts with #, it will be treated as a language token.
SelectionStart Int32
SelectionEnd Int32
SelectionColor Color The color used for text selection highlight
Text virtual String Text to display on the label.
IsRich Boolean Set to true if this is rich text. This means it can support some inline html elements.
CaretPosition Int32 Position of the text cursor/caret within the text, at which newly typed characters are inserted.
TextLength Int32 Amount of characters in the text of the text entry. Not bytes.
Multiline Boolean Enables multi-line support for editing purposes.

Methods

virtual Void OnDeleted()
virtual Void SetProperty(String name, String value)
virtual Void SetContent(String value)
String GetSelectedText()

Returns the selected text.

virtual String GetClipboardValue(Boolean cut)
Rect GetCaretRect(Int32 i)
virtual Void FinalLayout(Vector2 offset)
Int32 GetLetterAt(Vector2 pos)
Int32 GetLetterAtScreenPosition(Vector2 pos)
Boolean HasSelection()
virtual Void LanguageChanged()

When the language changes, if we're token based we need to update to the new phrase.

Void ReplaceSelection(String str)

Replace the currently selected text with given text.

Void SetSelection(Int32 start, Int32 end)

Sets the text selection.

Void SetCaretPosition(Int32 pos, Boolean select = False)

Set the text caret position to the given index.

pos — Where to move the text caret to within the text.
select — Whether to also add the characters we passed by to the selection.
Void ScrollToCaret()

Put the caret within the visible region.

Void MoveToWordBoundaryLeft(Boolean select)

Move the text caret to the closest word start or end to the left of current position. This simulates holding Control key while pressing left arrow key.

select — Whether to also add the characters we passed by to the selection.
Void MoveToWordBoundaryRight(Boolean select)

Move the text caret to the closest word start or end to the right of current position. This simulates holding Control key while pressing right arrow key.

select — Whether to also add the characters we passed by to the selection.
Void MoveCaretPos(Int32 delta, Boolean select = False)

Move the text caret by given amount.

delta — How many characters to the right to move. Negative values move left.
select — Whether to also add the characters we passed by to the selection.
Void InsertText(String text, Int32 pos, Int32? endpos = null)
virtual Void RemoveText(Int32 start, Int32 count)

Remove given amount of characters from the label at given position.

Void MoveToLineStart(Boolean select = False)

Move the text caret to the start of the current line.

select — Whether to also add the characters we passed by to the selection.
Void MoveToLineEnd(Boolean select = False)

Move the text caret to the end of the current line.

select — Whether to also add the characters we passed by to the selection.
Void MoveCaretLine(Int32 offset_line, Boolean select)

Move the text caret to next or previous line.

offset_line — How many lines to offset. Negative values move up.
select — Whether to also add the characters we passed by to the selection.
Void SelectWord(Int32 wordPos)

Select a work at given word position.

List<Int32> GetWordBoundaryIndices()

Returns a list of positions in the text of each side of each word within the Text. This is used for Control + Arrow Key navigation.

Assembly: Sandbox.Engine Namespace: Sandbox.UI Full Name: Sandbox.UI.Label