s&box docs
API ReferenceSandbox.UI

public class Sandbox.UI.Label : Sandbox.UI.Panel

A generic text label. Can be made editable.

Broader workflow and conceptual references connected to this API.

Constructors

Showing 2 constructors

Methods

Showing 29 methods

protected void CaretSantity()

Ensure the text caret and selection are in sane positions, that is, not outside of the text bounds.

public virtual void FinalLayout(Vector2 offset)

public Sandbox.Rect GetCaretRect(int i)

public virtual string GetClipboardValue(bool cut)

public int GetLetterAt(Vector2 pos)

public int GetLetterAtScreenPosition(Vector2 pos)

public string GetSelectedText()

Returns the selected text.

public System.Collections.Generic.List`1<int> GetWordBoundaryIndices()

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

public bool HasSelection()

public void InsertText(string text, int pos, System.Nullable`1<int> endpos = null)

Parameters

  • endpos: Default: null

public virtual void LanguageChanged()

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

public void MoveCaretLine(int offset_line, bool select)

Move the text caret to next or previous line.

Parameters

  • offset_line: How many lines to offset. Negative values move up.
  • select: Whether to also add the characters we passed by to the selection.

public void MoveCaretPos(int delta, bool select = False)

Move the text caret by given amount.

Parameters

  • 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. Default: False

public void MoveToLineEnd(bool select = False)

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

Parameters

  • select: Whether to also add the characters we passed by to the selection. Default: False

public void MoveToLineStart(bool select = False)

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

Parameters

  • select: Whether to also add the characters we passed by to the selection. Default: False

public void MoveToWordBoundaryLeft(bool 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.

Parameters

  • select: Whether to also add the characters we passed by to the selection.

public void MoveToWordBoundaryRight(bool 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.

Parameters

  • select: Whether to also add the characters we passed by to the selection.

public virtual void OnDeleted()

public virtual void OnDraw()

public virtual void RemoveText(int start, int count)

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

public void ReplaceSelection(string str)

Replace the currently selected text with given text.

public void ScrollToCaret()

Put the caret within the visible region.

public void SelectWord(int wordPos)

Select a work at given word position.

public void SetCaretPosition(int pos, bool select = False)

Set the text caret position to the given index.

Parameters

  • pos: Where to move the text caret to within the text.
  • select: Whether to also add the characters we passed by to the selection. Default: False

public virtual void SetContent(string value)

public virtual void SetProperty(string name, string value)

public void SetSelection(int start, int end)

Sets the text selection.

Properties

Showing 11 properties

public int Sandbox.UI.Label.CaretPosition { get; set; }

Position of the text cursor/caret within the text, at which newly typed characters are inserted.

public bool Sandbox.UI.Label.IsRich { get; set; }

Set to true if this is rich text. This means it can support some inline html elements.

public bool Sandbox.UI.Label.Multiline { get; set; }

Enables multi-line support for editing purposes.

public bool Sandbox.UI.Label.Selectable { get; set; }

Can be selected

public Color Sandbox.UI.Label.SelectionColor { get; set; }

The color used for text selection highlight

public int Sandbox.UI.Label.SelectionEnd { get; set; }

public int Sandbox.UI.Label.SelectionStart { get; set; }

public bool Sandbox.UI.Label.ShouldDrawSelection { get; set; }

public virtual string Sandbox.UI.Label.Text { get; set; }

Text to display on the label.

public int Sandbox.UI.Label.TextLength { get; set; }

Amount of characters in the text of the text entry. Not bytes.

public bool Sandbox.UI.Label.Tokenize { get; set; }

If true and the text starts with #, it will be treated as a language token.

Metadata

FieldValue
NamespaceSandbox.UI
Typeclass
AssemblySandbox.Engine
Doc IDT:Sandbox.UI.Label

On this page

Constructorspublic Label()public Label(System.String text, System.String classname = null)Methodsprotected System.Void CaretSantity()public virtual System.Void FinalLayout(Vector2 offset)public Sandbox.Rect GetCaretRect(System.Int32 i)public virtual System.String GetClipboardValue(System.Boolean cut)public System.Int32 GetLetterAt(Vector2 pos)public System.Int32 GetLetterAtScreenPosition(Vector2 pos)public System.String GetSelectedText()public System.Collections.Generic.List`1<System.Int32> GetWordBoundaryIndices()public System.Boolean HasSelection()public System.Void InsertText(System.String text, System.Int32 pos, System.Nullable`1<System.Int32> endpos = null)public virtual System.Void LanguageChanged()public System.Void MoveCaretLine(System.Int32 offset_line, System.Boolean select)public System.Void MoveCaretPos(System.Int32 delta, System.Boolean select = False)public System.Void MoveToLineEnd(System.Boolean select = False)public System.Void MoveToLineStart(System.Boolean select = False)public System.Void MoveToWordBoundaryLeft(System.Boolean select)public System.Void MoveToWordBoundaryRight(System.Boolean select)protected virtual System.Void OnClick(Sandbox.UI.MousePanelEvent e)public virtual System.Void OnDeleted()public virtual System.Void OnDraw()protected virtual System.Void OnMouseMove(Sandbox.UI.MousePanelEvent e)public virtual System.Void RemoveText(System.Int32 start, System.Int32 count)public System.Void ReplaceSelection(System.String str)public System.Void ScrollToCaret()public System.Void SelectWord(System.Int32 wordPos)public System.Void SetCaretPosition(System.Int32 pos, System.Boolean select = False)public virtual System.Void SetContent(System.String value)public virtual System.Void SetProperty(System.String name, System.String value)public System.Void SetSelection(System.Int32 start, System.Int32 end)Propertiespublic System.Int32 Sandbox.UI.Label.CaretPosition { get; set; }public System.Boolean Sandbox.UI.Label.IsRich { get; set; }public System.Boolean Sandbox.UI.Label.Multiline { get; set; }public System.Boolean Sandbox.UI.Label.Selectable { get; set; }public Color Sandbox.UI.Label.SelectionColor { get; set; }public System.Int32 Sandbox.UI.Label.SelectionEnd { get; set; }public System.Int32 Sandbox.UI.Label.SelectionStart { get; set; }public System.Boolean Sandbox.UI.Label.ShouldDrawSelection { get; set; }public virtual System.String Sandbox.UI.Label.Text { get; set; }public System.Int32 Sandbox.UI.Label.TextLength { get; set; }public System.Boolean Sandbox.UI.Label.Tokenize { get; set; }Metadata