Class TextBox
Text box control which can gather text input from the user.
Implements
Namespace: FlaxEngine.GUI
Assembly: FlaxEngine.CSharp.dll
Syntax
[ActorToolbox("GUI")]
public class TextBox : TextBoxBase, IComparable, IDrawable
Constructors
TextBox()
TextBox(Boolean, Single, Single, Single)
Init
Declaration
public TextBox(bool isMultiline, float x, float y, float width = 120F)
Parameters
System.Boolean
isMultiline
Enable/disable multiline text input support |
System.Single
x
Position X coordinate |
System.Single
y
Position Y coordinate |
System.Single
width
Width |
Fields
_watermarkText
The watermark text.
Declaration
protected LocalizedString _watermarkText
Field Value
LocalizedString
|
Properties
Bold
Whether to bold the text.
Declaration
[EditorDisplay("Text Style", null)]
[EditorOrder(2001)]
[Tooltip("Bold the text.")]
public bool Bold { get; set; }
Property Value
System.Boolean
|
CaseOption
The text case.
Declaration
[EditorDisplay("Text Style", null)]
[EditorOrder(2000)]
[Tooltip("The case of the text.")]
public TextCaseOptions CaseOption { get; set; }
Property Value
TextCaseOptions
|
Font
Gets or sets the font.
Declaration
[EditorDisplay("Text Style", null)]
[EditorOrder(2026)]
public FontReference Font { get; set; }
Property Value
FontReference
|
HorizontalAlignment
The vertical alignment of the text.
Declaration
[EditorDisplay("Text Style", null)]
[EditorOrder(2024)]
[Tooltip("The horizontal alignment of the text.")]
public TextAlignment HorizontalAlignment { get; set; }
Property Value
TextAlignment
|
Italic
Whether to italicize the text.
Declaration
[EditorDisplay("Text Style", null)]
[EditorOrder(2002)]
[Tooltip("Italicize the text.")]
public bool Italic { get; set; }
Property Value
System.Boolean
|
SelectionColor
Gets or sets the color of the selection (Transparent if not used).
Declaration
[EditorDisplay("Text Style", null)]
[EditorOrder(2022)]
[Tooltip("The color of the selection (Transparent if not used).")]
public Color SelectionColor { get; set; }
Property Value
Color
|
TextColor
Gets or sets the color of the text.
Declaration
[EditorDisplay("Text Style", null)]
[EditorOrder(2020)]
[Tooltip("The color of the text.")]
[ExpandGroups]
public Color TextColor { get; set; }
Property Value
Color
|
TextMaterial
Gets or sets the custom material used to render the text. It must has domain set to GUI and have a public texture parameter named Font used to sample font atlas texture with font characters data.
Declaration
[EditorDisplay("Text Style", null)]
[EditorOrder(2027)]
[Tooltip("Custom material used to render the text. It must has domain set to GUI and have a public texture parameter named Font used to sample font atlas texture with font characters data.")]
public MaterialBase TextMaterial { get; set; }
Property Value
MaterialBase
|
VerticalAlignment
The vertical alignment of the text.
Declaration
[EditorDisplay("Text Style", null)]
[EditorOrder(2023)]
[Tooltip("The vertical alignment of the text.")]
public TextAlignment VerticalAlignment { get; set; }
Property Value
TextAlignment
|
WatermarkText
Gets or sets the watermark text to show grayed when textbox is empty.
Declaration
[EditorOrder(20)]
[Tooltip("The watermark text to show grayed when textbox is empty.")]
public LocalizedString WatermarkText { get; set; }
Property Value
LocalizedString
|
WatermarkTextColor
Gets or sets the color of the text.
Declaration
[EditorDisplay("Text Style", null)]
[EditorOrder(2021)]
[Tooltip("The color of the watermark text.")]
public Color WatermarkTextColor { get; set; }
Property Value
Color
|
Wrapping
Gets or sets the text wrapping within the control bounds.
Declaration
[EditorDisplay("Text Style", null)]
[EditorOrder(2025)]
[Tooltip("The text wrapping within the control bounds.")]
public TextWrapping Wrapping { get; set; }
Property Value
TextWrapping
|
Methods
DrawSelf()
Draws the control.
Declaration
public override void DrawSelf()
Overrides
GetCharPosition(Int32, out Single)
Calculates character position for given character index.
Declaration
public override Float2 GetCharPosition(int index, out float height)
Parameters
System.Int32
index
The text position to get it's coordinates. |
System.Single
height
The character height (at the given character position). |
Returns
Float2
The character position (upper left corner which can be used for a caret position). |
Overrides
GetTextSize()
Calculates total text size. Called by OnTextChanged() to cache the text size.
Declaration
public override Float2 GetTextSize()
Returns
Float2
The total text size. |
Overrides
HitTestText(Float2)
Calculates hit character index at given location.
Declaration
public override int HitTestText(Float2 location)
Parameters
Float2
location
The location to test. |
Returns
System.Int32
The selected character position index (can be equal to text length if location is outside of the layout rectangle). |
Overrides
OnIsMultilineChanged()
Called when is multiline gets changed.
Declaration
protected override void OnIsMultilineChanged()
Overrides
OnMouseDoubleClick(Float2, MouseButton)
When mouse double clicks over control's area
Declaration
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
Parameters
Float2
location
Mouse location in Control Space |
MouseButton
button
Mouse buttons state (flags) |
Returns
System.Boolean
True if event has been handled, otherwise false |
Overrides
OnSizeChanged()
Called when control size gets changed.
Declaration
protected override void OnSizeChanged()