Table of Contents

Class TextBlock

Namespace
Stride.UI.Controls
Assembly
Stride.UI.dll

Provides a lightweight control for displaying small amounts of text.

[DataContract("TextBlock")]
public class TextBlock : UIElement, IUIElementUpdate, IUIElementChildren, IIdentifiable
Inheritance
TextBlock
Implements
Derived
Inherited Members
Extension Methods

Properties

ActualTextSize

Returns the actual size of the text in virtual pixels unit.

public float ActualTextSize { get; }

Property Value

float

Remarks

If TextSize is IsNaN(float), returns the default size of the Font.

See Also

DoNotSnapText

Gets or sets the value indicating if the snapping of the Text of the TextBlock to the closest screen pixel should be skipped.

[DataMember]
[Display(null, "Behavior")]
public bool DoNotSnapText { get; set; }

Property Value

bool

Remarks

When true, the element's text is never snapped. When false, it is snapped only if the font is dynamic and the element is rendered by a SceneUIRenderer.

Font

Gets or sets the font of the text block.

[DataMember]
[Display(null, "Appearance")]
public SpriteFont Font { get; set; }

Property Value

SpriteFont

SynchronousCharacterGeneration

Gets or sets the value indicating if the text block should generate RuntimeRasterizedSpriteFont characters synchronously or asynchronously.

[DataMember]
[Display(null, "Behavior")]
public bool SynchronousCharacterGeneration { get; set; }

Property Value

bool

Remarks

If synchronous generation is activated, the game will be block until all the characters have finished to be generate. If asynchronous generation is activated, some characters can appears with one or two frames of delay.

Text

Gets or sets the text of the text block.

[DataMember]
public string Text { get; set; }

Property Value

string

TextAlignment

Gets or sets the alignment of the text to display.

[DataMember]
[Display(null, "Appearance")]
public TextAlignment TextAlignment { get; set; }

Property Value

TextAlignment

TextColor

Gets or sets the color of the text.

[DataMember]
[Display(null, "Appearance")]
public Color TextColor { get; set; }

Property Value

Color

TextSize

Gets or sets the size of the text in virtual pixels unit.

[DataMember]
[DataMemberRange(0, 3)]
[Display(null, "Appearance")]
public float TextSize { get; set; }

Property Value

float

Remarks

If the value set is null, the default size of the Font will be used instead.

See Also

TextToDisplay

Returns the text to display during the draw call.

public virtual string TextToDisplay { get; }

Property Value

string

WrapText

Gets or sets the value indicating if the Text of the TextBlock should automatically return to the beginning of the line when it is too long for the line width.

[DataMember]
[Display(null, "Behavior")]
public bool WrapText { get; set; }

Property Value

bool

Methods

ArrangeOverride(Vector3)

When overridden in a derived class, positions possible child elements and determines a size for a UIElement derived class.

protected override Vector3 ArrangeOverride(Vector3 finalSizeWithoutMargins)

Parameters

finalSizeWithoutMargins Vector3

The final area within the parent that this element should use to arrange itself and its children.

Returns

Vector3

The actual size used.

CalculateTextSize()

Calculate and returns the size of the Text in virtual pixels size.

public Vector2 CalculateTextSize()

Returns

Vector2

The size of the Text in virtual pixels.

CalculateTextSize(string)

Calculate and returns the size of the provided textToMeasure"/> in virtual pixels size.

protected Vector2 CalculateTextSize(string textToMeasure)

Parameters

textToMeasure string

The text to measure

Returns

Vector2

The size of the text in virtual pixels

MeasureOverride(Vector3)

When overridden in a derived class, measures the size in layout required for possible child elements and determines a size for the UIElement-derived class.

protected override Vector3 MeasureOverride(Vector3 availableSizeWithoutMargins)

Parameters

availableSizeWithoutMargins Vector3

The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available.

Returns

Vector3

The size desired by the children

OnTextChanged()

Method triggered when the Text changes. Can be overridden in inherited class to changed the default behavior.

protected virtual void OnTextChanged()