Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    EditText Class

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

    Represent an edit text where the user can enter text.

    System.Object → UIElement → Control → EditText
    Derived from EditText:

    [DataContract("EditText")]
    [Display(null, "Input")]
    public class EditText : Control, IUIElementUpdate, IUIElementChildren, IIdentifiable
    Name Description
    Constructors
    EditText()

    Create a new instance of EditText.

    Fields
    TextChangedEvent

    Identifies the TextChanged routed event.

    Properties
    ActiveImage

    Gets or sets the image that is displayed in background when the edit is active.

    ActualTextSize

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

    CaretColor

    Gets or sets the color of the caret.

    CaretFrequency

    Gets or sets the caret blinking frequency.

    CaretPosition

    Gets or sets the caret position in the EditText's text.

    CaretWidth

    Gets or sets the width of the edit text's cursor (in virtual pixels).

    CharacterFilterPredicate

    Gets or sets the filter used to determine whether the inputed characters are valid or not. Accepted character are characters that the provided predicate function returns true.

    Composition
    CompositionLength
    CompositionStart
    DoNotSnapText

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

    Font

    Gets or sets the font of the text block.

    IMESelectionColor

    Gets or sets the color of the IME composition selection.

    InactiveImage

    Gets or sets the image that is displayed in background when the edit is inactive.

    InputType

    Gets or sets the edit text input type by setting a combination of EditText.InputTypeFlags.

    IsCaretVisible

    Gets the value indicating if the blinking caret is currently visible or not.

    IsEnabled
    IsReadOnly

    Gets or sets whether the control is read-only, or not.

    IsSelectionActive

    Gets a value that indicates whether the text box has focus and selected text.

    IsTouchedDown

    Gets a value that indicates whether the is currently touched down.

    LineCount

    Gets the total number of lines in the text box.

    MaxLength

    Gets or sets the maximum number of characters that can be manually entered into the text box.

    MaxLines

    Gets or sets the maximum number of visible lines.

    MinLines

    Gets or sets the minimum number of visible lines.

    MouseOverImage

    Gets or sets the image that the button displays when the mouse is over it.

    SelectedText

    Gets or sets the content of the current selection in the text box.

    SelectionColor

    Gets or sets the color of the selection.

    SelectionLength

    Gets or sets a value indicating the number of characters in the current selection in the text box.

    SelectionStart

    Gets or sets a character index for the beginning of the current selection.

    ShouldHideText

    Gets a value indicating if the text should be hidden when displayed.

    SynchronousCharacterGeneration

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

    Text

    Gets or sets the text content of the text box.

    TextAlignment

    Gets or sets the alignment of the text to display.

    TextColor

    Gets or sets the color of the text.

    TextSize

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

    TextToDisplay

    The actual text to show into the edit text.

    Methods
    AppendText(String)

    Appends a string to the contents of a text control.

    ArrangeOverride(Vector3)
    CalculateTextSize()

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

    CalculateTextSize(String)

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

    Clear()

    Clears all the content from the text box.

    FindNearestCharacterIndex(Vector2)

    Find the index of the nearest character to the provided position.

    MeasureOverride(Vector3)
    OnIsReadOnlyChanged()

    Function triggered when the value of IsReadOnly changed.

    OnMaxLengthChanged()

    Function triggered when the value of MaxLength changed.

    OnMaxLinesChanged()

    Function triggered when the value of MaxLines changed.

    OnMinLinesChanged()

    Function triggered when the value of MinLines changed.

    OnTextChanged(RoutedEventArgs)

    The class handler of the event TextChanged. This method can be overridden in inherited classes to perform actions common to all instances of a class.

    OnTouchDown(TouchEventArgs)
    OnTouchLeave(TouchEventArgs)
    OnTouchMove(TouchEventArgs)
    OnTouchUp(TouchEventArgs)
    ResetCaretBlinking()

    Reset the caret blinking to initial state (visible).

    Select(Int32, Int32, Boolean)

    Selects a range of text in the text box.

    SelectAll(Boolean)

    Selects all the contents of the text editing control.

    Update(GameTime)
    Events
    TextChanged

    Occurs when the text selection has changed.

    | Improve this Doc View Source

    Constructors


    EditText()

    Create a new instance of EditText.

    public EditText()
    | Improve this Doc View Source

    Fields


    TextChangedEvent

    Identifies the TextChanged routed event.

    public static readonly RoutedEvent<RoutedEventArgs> TextChangedEvent
    Field Value
    Type Description
    RoutedEvent<RoutedEventArgs>
    | Improve this Doc View Source

    Properties


    ActiveImage

    Gets or sets the image that is displayed in background when the edit is active.

    [DataMember]
    [Display(null, "Appearance")]
    public ISpriteProvider ActiveImage { get; set; }
    Property Value
    Type Description
    ISpriteProvider

    ActualTextSize

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

    public float ActualTextSize { get; }
    Property Value
    Type Description
    System.Single
    Remarks

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

    See Also
    TextSize
    Size

    CaretColor

    Gets or sets the color of the caret.

    [DataMember]
    [Display(null, "Appearance")]
    public Color CaretColor { get; set; }
    Property Value
    Type Description
    Color

    CaretFrequency

    Gets or sets the caret blinking frequency.

    [DataMember]
    [DataMemberRange(0, 3)]
    [Display(null, "Behavior")]
    public float CaretFrequency { get; set; }
    Property Value
    Type Description
    System.Single
    Remarks

    The value is coerced in the range [0, System.Single.MaxValue].


    CaretPosition

    Gets or sets the caret position in the EditText's text.

    public int CaretPosition { get; set; }
    Property Value
    Type Description
    System.Int32

    CaretWidth

    Gets or sets the width of the edit text's cursor (in virtual pixels).

    [DataMember]
    [DataMemberRange(0, 2)]
    [Display(null, "Appearance")]
    public float CaretWidth { get; set; }
    Property Value
    Type Description
    System.Single
    Remarks

    The value is coerced in the range [0, System.Single.MaxValue].


    CharacterFilterPredicate

    Gets or sets the filter used to determine whether the inputed characters are valid or not. Accepted character are characters that the provided predicate function returns true.

    public Func<char, bool> CharacterFilterPredicate { get; set; }
    Property Value
    Type Description
    System.Func<System.Char, System.Boolean>
    Remarks

    If CharacterFilterPredicate is not set all characters are accepted.


    Composition

    public string Composition { get; }
    Property Value
    Type Description
    System.String

    CompositionLength

    public int CompositionLength { get; }
    Property Value
    Type Description
    System.Int32

    CompositionStart

    public int CompositionStart { get; }
    Property Value
    Type Description
    System.Int32

    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
    Type Description
    System.Boolean
    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
    Type Description
    SpriteFont

    IMESelectionColor

    Gets or sets the color of the IME composition selection.

    [DataMember]
    [Display(null, "Appearance")]
    public Color IMESelectionColor { get; set; }
    Property Value
    Type Description
    Color

    InactiveImage

    Gets or sets the image that is displayed in background when the edit is inactive.

    [DataMember]
    [Display(null, "Appearance")]
    public ISpriteProvider InactiveImage { get; set; }
    Property Value
    Type Description
    ISpriteProvider

    InputType

    Gets or sets the edit text input type by setting a combination of EditText.InputTypeFlags.

    [DataMember]
    [Display(null, "Behavior")]
    public EditText.InputTypeFlags InputType { get; set; }
    Property Value
    Type Description
    EditText.InputTypeFlags

    IsCaretVisible

    Gets the value indicating if the blinking caret is currently visible or not.

    public bool IsCaretVisible { get; }
    Property Value
    Type Description
    System.Boolean

    IsEnabled

    public override bool IsEnabled { set; }
    Property Value
    Type Description
    System.Boolean
    Overrides
    UIElement.IsEnabled

    IsReadOnly

    Gets or sets whether the control is read-only, or not.

    [DataMember]
    [Display(null, "Behavior")]
    public bool IsReadOnly { get; set; }
    Property Value
    Type Description
    System.Boolean

    IsSelectionActive

    Gets a value that indicates whether the text box has focus and selected text.

    public bool IsSelectionActive { get; set; }
    Property Value
    Type Description
    System.Boolean

    IsTouchedDown

    Gets a value that indicates whether the is currently touched down.

    protected virtual bool IsTouchedDown { get; set; }
    Property Value
    Type Description
    System.Boolean

    LineCount

    Gets the total number of lines in the text box.

    public int LineCount { get; }
    Property Value
    Type Description
    System.Int32

    MaxLength

    Gets or sets the maximum number of characters that can be manually entered into the text box.

    [DataMember]
    [DataMemberRange(1, 0)]
    [Display(null, "Behavior")]
    public int MaxLength { get; set; }
    Property Value
    Type Description
    System.Int32
    Remarks

    The value is coerced in the range [1, System.Int32.MaxValue].


    MaxLines

    Gets or sets the maximum number of visible lines.

    [DataMember]
    [DataMemberRange(1, 0)]
    [Display(null, "Behavior")]
    public int MaxLines { get; set; }
    Property Value
    Type Description
    System.Int32
    Remarks

    The value is coerced in the range [int, System.Int32.MaxValue].


    MinLines

    Gets or sets the minimum number of visible lines.

    [DataMember]
    [DataMemberRange(1, 0)]
    [Display(null, "Behavior")]
    public int MinLines { get; set; }
    Property Value
    Type Description
    System.Int32
    Remarks

    The value is coerced in the range [1, System.Int32.MaxValue].


    MouseOverImage

    Gets or sets the image that the button displays when the mouse is over it.

    [DataMember]
    [Display(null, "Appearance")]
    public ISpriteProvider MouseOverImage { get; set; }
    Property Value
    Type Description
    ISpriteProvider

    SelectedText

    Gets or sets the content of the current selection in the text box.

    public string SelectedText { get; set; }
    Property Value
    Type Description
    System.String
    Exceptions
    Type Condition
    System.ArgumentNullException

    The provided string value is null


    SelectionColor

    Gets or sets the color of the selection.

    [DataMember]
    [Display(null, "Appearance")]
    public Color SelectionColor { get; set; }
    Property Value
    Type Description
    Color

    SelectionLength

    Gets or sets a value indicating the number of characters in the current selection in the text box.

    public int SelectionLength { get; set; }
    Property Value
    Type Description
    System.Int32
    Remarks

    If the provided length of the selection is too big, the selection is extended until the end of the current text


    SelectionStart

    Gets or sets a character index for the beginning of the current selection.

    public int SelectionStart { get; set; }
    Property Value
    Type Description
    System.Int32
    Remarks

    If the provided selection start index is too big, the caret is placed at the end of the current text


    ShouldHideText

    Gets a value indicating if the text should be hidden when displayed.

    protected bool ShouldHideText { get; }
    Property Value
    Type Description
    System.Boolean

    SynchronousCharacterGeneration

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

    [DataMember]
    public bool SynchronousCharacterGeneration { get; set; }
    Property Value
    Type Description
    System.Boolean
    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 content of the text box.

    [DataMember]
    public string Text { get; set; }
    Property Value
    Type Description
    System.String
    Remarks

    Setting explicitly the text sets the cursor at the end of the new text.


    TextAlignment

    Gets or sets the alignment of the text to display.

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

    TextColor

    Gets or sets the color of the text.

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

    TextSize

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

    [DataMember]
    [DataMemberRange(0, 2)]
    [Display(null, "Appearance")]
    public float TextSize { get; set; }
    Property Value
    Type Description
    System.Single
    Remarks

    The value is coerced in the range [0, System.Single.MaxValue].


    TextToDisplay

    The actual text to show into the edit text.

    public string TextToDisplay { get; }
    Property Value
    Type Description
    System.String
    | Improve this Doc View Source

    Methods


    AppendText(String)

    Appends a string to the contents of a text control.

    public void AppendText(string textData)
    Parameters
    Type Name Description
    System.String textData

    A string that specifies the text to append to the current contents of the text control.


    ArrangeOverride(Vector3)

    protected override Vector3 ArrangeOverride(Vector3 finalSizeWithoutMargins)
    Parameters
    Type Name Description
    Vector3 finalSizeWithoutMargins
    Returns
    Type Description
    Vector3
    Overrides
    UIElement.ArrangeOverride(Vector3)

    CalculateTextSize()

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

    public Vector2 CalculateTextSize()
    Returns
    Type Description
    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
    Type Name Description
    System.String textToMeasure

    The text to measure

    Returns
    Type Description
    Vector2

    The size of the text in virtual pixels


    Clear()

    Clears all the content from the text box.

    public void Clear()

    FindNearestCharacterIndex(Vector2)

    Find the index of the nearest character to the provided position.

    protected virtual int FindNearestCharacterIndex(Vector2 position)
    Parameters
    Type Name Description
    Vector2 position

    The position in edit text space

    Returns
    Type Description
    System.Int32

    The 0-based index of the nearest character


    MeasureOverride(Vector3)

    protected override Vector3 MeasureOverride(Vector3 availableSizeWithoutMargins)
    Parameters
    Type Name Description
    Vector3 availableSizeWithoutMargins
    Returns
    Type Description
    Vector3
    Overrides
    UIElement.MeasureOverride(Vector3)

    OnIsReadOnlyChanged()

    Function triggered when the value of IsReadOnly changed.

    protected virtual void OnIsReadOnlyChanged()

    OnMaxLengthChanged()

    Function triggered when the value of MaxLength changed.

    protected virtual void OnMaxLengthChanged()

    OnMaxLinesChanged()

    Function triggered when the value of MaxLines changed.

    protected virtual void OnMaxLinesChanged()

    OnMinLinesChanged()

    Function triggered when the value of MinLines changed.

    protected virtual void OnMinLinesChanged()

    OnTextChanged(RoutedEventArgs)

    The class handler of the event TextChanged. This method can be overridden in inherited classes to perform actions common to all instances of a class.

    protected virtual void OnTextChanged(RoutedEventArgs args)
    Parameters
    Type Name Description
    RoutedEventArgs args

    The arguments of the event


    OnTouchDown(TouchEventArgs)

    protected override void OnTouchDown(TouchEventArgs args)
    Parameters
    Type Name Description
    TouchEventArgs args
    Overrides
    UIElement.OnTouchDown(TouchEventArgs)

    OnTouchLeave(TouchEventArgs)

    protected override void OnTouchLeave(TouchEventArgs args)
    Parameters
    Type Name Description
    TouchEventArgs args
    Overrides
    UIElement.OnTouchLeave(TouchEventArgs)

    OnTouchMove(TouchEventArgs)

    protected override void OnTouchMove(TouchEventArgs args)
    Parameters
    Type Name Description
    TouchEventArgs args
    Overrides
    UIElement.OnTouchMove(TouchEventArgs)

    OnTouchUp(TouchEventArgs)

    protected override void OnTouchUp(TouchEventArgs args)
    Parameters
    Type Name Description
    TouchEventArgs args
    Overrides
    UIElement.OnTouchUp(TouchEventArgs)

    ResetCaretBlinking()

    Reset the caret blinking to initial state (visible).

    public void ResetCaretBlinking()

    Select(Int32, Int32, Boolean)

    Selects a range of text in the text box.

    public void Select(int start, int length, bool caretAtBeginning = false)
    Parameters
    Type Name Description
    System.Int32 start

    The zero-based character index of the first character in the selection.

    System.Int32 length

    The length of the selection, in characters.

    System.Boolean caretAtBeginning

    Indicate if the caret should be at the beginning or the end of the selection

    Remarks

    If the value of start is too big the caret is positioned at the end of the current text. If the value of length is too big the selection is extended to the end current text.


    SelectAll(Boolean)

    Selects all the contents of the text editing control.

    public void SelectAll(bool caretAtBeginning = false)
    Parameters
    Type Name Description
    System.Boolean caretAtBeginning

    Indicate if the caret should be at the beginning or the end of the selection


    Update(GameTime)

    protected override void Update(GameTime time)
    Parameters
    Type Name Description
    GameTime time
    Overrides
    UIElement.Update(GameTime)
    | Improve this Doc View Source

    Events


    TextChanged

    Occurs when the text selection has changed.

    public event EventHandler<RoutedEventArgs> TextChanged
    Event Type
    Type Description
    System.EventHandler<RoutedEventArgs>
    Remarks

    A click event is bubbling


    Inherited Members

    Control.padding
    Control.Padding
    UIElement.InputCategory
    UIElement.PanelCategory
    UIElement.AppearanceCategory
    UIElement.BehaviorCategory
    UIElement.LayoutCategory
    UIElement.MiscCategory
    UIElement.MarginInternal
    UIElement.ArrangeChanged
    UIElement.LocalMatrixChanged
    UIElement.Id
    UIElement.DependencyProperties
    UIElement.LocalMatrix
    UIElement.BackgroundColor
    UIElement.Opacity
    UIElement.Visibility
    UIElement.ClipToBounds
    UIElement.DrawLayerNumber
    UIElement.CanBeHitByUser
    UIElement.Width
    UIElement.Height
    UIElement.Depth
    UIElement.Size
    UIElement.HorizontalAlignment
    UIElement.VerticalAlignment
    UIElement.DepthAlignment
    UIElement.Margin
    UIElement.MinimumWidth
    UIElement.MinimumHeight
    UIElement.MinimumDepth
    UIElement.MaximumWidth
    UIElement.MaximumHeight
    UIElement.MaximumDepth
    UIElement.DefaultWidth
    UIElement.DefaultHeight
    UIElement.DefaultDepth
    UIElement.Name
    UIElement.DesiredSize
    UIElement.DesiredSizeWithMargins
    UIElement.IsArrangeValid
    UIElement.IsMeasureValid
    UIElement.WorldMatrix
    UIElement.DepthBias
    UIElement.LayoutingContext
    UIElement.VisualChildrenCollection
    UIElement.InvalidateArrange()
    UIElement.InvalidateMeasure()
    UIElement.OnNameChanged()
    UIElement.IsHierarchyEnabled
    UIElement.IsVisible
    UIElement.IsCollapsed
    UIElement.Parent
    UIElement.VisualParent
    UIElement.VisualChildren
    UIElement.HitableChildren
    UIElement.RenderOpacity
    UIElement.RenderSize
    UIElement.RenderOffsets
    UIElement.ActualWidth
    UIElement.ActualHeight
    UIElement.ActualDepth
    UIElement.IUIElementChildren.Children
    UIElement.EnumerateChildren()
    UIElement.Measure(Vector3)
    UIElement.Arrange(Vector3, Boolean)
    UIElement.CollapseOverride()
    UIElement.PropagateCollapseToChild(UIElement)
    UIElement.FindName(String)
    UIElement.SetParent(UIElement, UIElement)
    UIElement.SetVisualParent(UIElement, UIElement)
    UIElement.Intersects(Ray, Vector3)
    UIElement.IUIElementUpdate.Update(GameTime)
    UIElement.IUIElementUpdate.UpdateWorldMatrix(Matrix, Boolean)
    UIElement.IUIElementUpdate.UpdateElementState(Int32)
    UIElement.UpdateWorldMatrix(Matrix, Boolean)
    UIElement.CalculateSizeWithThickness(Vector3, Thickness)
    UIElement.CalculateSizeWithoutThickness(Vector3, Thickness)
    UIElement.CalculateAdjustmentOffsets(Thickness, Vector3, Vector3)
    UIElement.IsTouched
    UIElement.MouseOverState
    UIElement.RequiresMouseOverUpdate
    UIElement.RaiseEvent(RoutedEventArgs)
    UIElement.AddHandler<T>(RoutedEvent<T>, EventHandler<T>, Boolean)
    UIElement.RemoveHandler<T>(RoutedEvent<T>, EventHandler<T>)
    UIElement.MouseOverStateChanged
    UIElement.PreviewTouchDown
    UIElement.PreviewTouchMove
    UIElement.PreviewTouchUp
    UIElement.TouchDown
    UIElement.TouchEnter
    UIElement.TouchLeave
    UIElement.TouchMove
    UIElement.TouchUp
    UIElement.OnPreviewTouchDown(TouchEventArgs)
    UIElement.OnPreviewTouchMove(TouchEventArgs)
    UIElement.OnPreviewTouchUp(TouchEventArgs)
    UIElement.OnTouchEnter(TouchEventArgs)

    Extension Methods

    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    UIElementExtensions.SetPanelZIndex(UIElement, Int32)
    UIElementExtensions.GetPanelZIndex(UIElement)
    UIElementExtensions.SetCanvasRelativeSize(UIElement, Vector3)
    UIElementExtensions.GetCanvasRelativeSize(UIElement)
    UIElementExtensions.SetCanvasRelativePosition(UIElement, Vector3)
    UIElementExtensions.GetCanvasRelativePosition(UIElement)
    UIElementExtensions.SetCanvasAbsolutePosition(UIElement, Vector3)
    UIElementExtensions.GetCanvasAbsolutePosition(UIElement)
    UIElementExtensions.SetCanvasPinOrigin(UIElement, Vector3)
    UIElementExtensions.GetCanvasPinOrigin(UIElement)
    UIElementExtensions.SetGridColumn(UIElement, Int32)
    UIElementExtensions.GetGridColumn(UIElement)
    UIElementExtensions.SetGridRow(UIElement, Int32)
    UIElementExtensions.GetGridRow(UIElement)
    UIElementExtensions.SetGridLayer(UIElement, Int32)
    UIElementExtensions.GetGridLayer(UIElement)
    UIElementExtensions.SetGridColumnSpan(UIElement, Int32)
    UIElementExtensions.GetGridColumnSpan(UIElement)
    UIElementExtensions.SetGridRowSpan(UIElement, Int32)
    UIElementExtensions.GetGridRowSpan(UIElement)
    UIElementExtensions.SetGridLayerSpan(UIElement, Int32)
    UIElementExtensions.GetGridLayerSpan(UIElement)
    VisualTreeHelper.FindVisualChildOfType<T>(UIElement, String)
    VisualTreeHelper.FindVisualChildrenOfType<T>(UIElement)
    VisualTreeHelper.FindVisualParentOfType<T>(UIElement)
    VisualTreeHelper.FindVisualRoot(UIElement)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation