Skip to content

LineEdit

Eduard Gushchin edited this page Jul 1, 2026 · 3 revisions

Home | API by Category | Complete API Index | API Compatibility

Field Value
Full name Electron2D.LineEdit
Namespace Electron2D
Kind class
Category UI and Text

Overview

Provides a single-line text editing control.

Syntax

public class Electron2D.LineEdit : Electron2D.Control

Godot 4.7 C# profile compatibility

Profile: Electron2D 0.1.0 2D
Status: Supported / Parity verified
Out of profile: no
Godot reference: LineEdit

Single-line text input with caret, max length, placeholder, secret drawing, editing keys and text changed/submitted/rejected signals.

Remarks

LineEdit accepts focused keyboard text input, basic caret movement, deletion and submit input. It emits text_changed, text_submitted and text_change_rejected.

Thread Safety

This type is not synchronized. Create and mutate line edits on the main scene thread.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Control
  • Electron2D.InputEventKey

Members

Member Kind Summary
CaretColumn Property Gets or sets the caret column.
Editable Property Gets or sets whether user input can edit the text.
HorizontalAlignment Property Gets or sets the horizontal alignment used for drawing text.
MaxLength Property Gets or sets the maximum number of UTF-16 code units accepted by this control.
PlaceholderText Property Gets or sets the placeholder text drawn when Electron2D.LineEdit.Text is empty.
Secret Property Gets or sets whether text is drawn using Electron2D.LineEdit.SecretCharacter.
SecretCharacter Property Gets or sets the character string used when Electron2D.LineEdit.Secret is enabled.
Text Property Gets or sets the editable text.
Electron2D.LineEdit() Constructor Initializes a new instance of the Electron2D.LineEdit class.
Clear() Method Clears all text from this control.
DeleteCharAtCaret() Method Deletes the character before the caret.
DeleteText(System.Int32, System.Int32) Method Deletes text in the specified column range.
InsertTextAtCaret(System.String) Method Inserts text at the current caret column.
_Draw() Method Draws the text field background and current text.
_GetMinimumSize() Method Gets the minimum size requested by this line edit.
_GuiInput(Electron2D.InputEvent) Method Handles focused text input and editing keys.

Member Details

CaretColumn

Kind: Property

public System.Int32 CaretColumn { get; set; }

Summary

Gets or sets the caret column.

Remarks

The preview control stores one caret and no selection range.

Value

The caret position clamped to the range 0 through Electron2D.LineEdit.Text length.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.LineEdit.Text

Editable

Kind: Property

public System.Boolean Editable { get; set; }

Summary

Gets or sets whether user input can edit the text.

Remarks

Programmatic methods can still change text when this property is false.

Value

true when user input can change text; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.LineEdit._GuiInput(Electron2D.InputEvent)

HorizontalAlignment

Kind: Property

public Electron2D.HorizontalAlignment HorizontalAlignment { get; set; }

Summary

Gets or sets the horizontal alignment used for drawing text.

Remarks

Input editing still uses logical text order and a single caret.

Value

The alignment used inside Electron2D.Control.Size.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.LineEdit.HorizontalAlignment

MaxLength

Kind: Property

public System.Int32 MaxLength { get; set; }

Summary

Gets or sets the maximum number of UTF-16 code units accepted by this control.

Remarks

Reducing the maximum length truncates existing text and clamps the caret.

Value

0 for unlimited text, or a positive maximum length.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is negative.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.LineEdit.Text

PlaceholderText

Kind: Property

public System.String PlaceholderText { get; set; }

Summary

Gets or sets the placeholder text drawn when Electron2D.LineEdit.Text is empty.

Remarks

Assigning this property queues a redraw.

Value

The placeholder text. The value is never null.

Exceptions

  • System.ArgumentNullException: Thrown when the assigned value is null.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.LineEdit.Text

Secret

Kind: Property

public System.Boolean Secret { get; set; }

Summary

Gets or sets whether text is drawn using Electron2D.LineEdit.SecretCharacter.

Remarks

This property affects drawing only. The Electron2D.LineEdit.Text value remains unchanged.

Value

true to hide the actual text while drawing; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.LineEdit.SecretCharacter

SecretCharacter

Kind: Property

public System.String SecretCharacter { get; set; }

Summary

Gets or sets the character string used when Electron2D.LineEdit.Secret is enabled.

Remarks

The value is repeated once per UTF-16 code unit in the preview implementation.

Value

A non-empty string used for each hidden text element.

Exceptions

  • System.ArgumentException: Thrown when the assigned value is null, empty or whitespace.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.LineEdit.Secret

Text

Kind: Property

public System.String Text { get; set; }

Summary

Gets or sets the editable text.

Remarks

Assigning text applies Electron2D.LineEdit.MaxLength and clamps Electron2D.LineEdit.CaretColumn to the new text length.

Value

The current text value. The value is never null.

Exceptions

  • System.ArgumentNullException: Thrown when the assigned value is null.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.LineEdit

Electron2D.LineEdit()

Kind: Constructor

public Electron2D.LineEdit()

Summary

Initializes a new instance of the Electron2D.LineEdit class.

Remarks

The constructor registers text signals and enables focus by default.

Thread Safety

This constructor is not synchronized. Call it from the main scene thread.

Since

This constructor is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.LineEdit

Clear()

Kind: Method

public System.Void Clear()()

Summary

Clears all text from this control.

Remarks

The caret moves to column zero and text_changed is emitted when the text actually changes.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.LineEdit.Text

DeleteCharAtCaret()

Kind: Method

public System.Void DeleteCharAtCaret()()

Summary

Deletes the character before the caret.

Remarks

Calling this method at column zero is a no-op.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.LineEdit.CaretColumn

DeleteText(System.Int32, System.Int32)

Kind: Method

public System.Void DeleteText(System.Int32, System.Int32)(System.Int32 fromColumn, System.Int32 toColumn)

Summary

Deletes text in the specified column range.

Remarks

Columns are clamped to the current text range. Reversed ranges are normalized before deletion.

Parameters

  • fromColumn: The first column to delete.
  • toColumn: The column after the last deleted character.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.LineEdit.Text

InsertTextAtCaret(System.String)

Kind: Method

public System.Void InsertTextAtCaret(System.String)(System.String value)

Summary

Inserts text at the current caret column.

Remarks

The method applies Electron2D.LineEdit.MaxLength. Rejected overflow text is emitted through text_change_rejected.

Parameters

  • value: The text to insert.

Exceptions

  • System.ArgumentNullException: Thrown when value is null.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.LineEdit.CaretColumn

_Draw()

Kind: Method

public System.Void _Draw()()

Summary

Draws the text field background and current text.

Remarks

The preview implementation uses rectangle primitives and theme font overrides.

Thread Safety

This callback is invoked on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CanvasItem.DrawString(Electron2D.Font,Electron2D.Vector2,System.String,Electron2D.HorizontalAlignment,System.Single,System.Int32,System.Nullable{Electron2D.Color})

_GetMinimumSize()

Kind: Method

public Electron2D.Vector2 _GetMinimumSize()()

Summary

Gets the minimum size requested by this line edit.

Remarks

If no font is available, the method returns 96x24.

Returns

A conservative text-field size based on theme font state.

Thread Safety

This callback is invoked on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Control.GetMinimumSize

_GuiInput(Electron2D.InputEvent)

Kind: Method

public System.Void _GuiInput(Electron2D.InputEvent)(Electron2D.InputEvent inputEvent)

Summary

Handles focused text input and editing keys.

Remarks

Unsupported input events are ignored.

Parameters

  • inputEvent: The input event delivered by the viewport.

Thread Safety

This callback is invoked on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Control._GuiInput(Electron2D.InputEvent)

Clone this wiki locally