ConsoleForge 0.3.0
Elm-architecture TUI framework for .NET 8
Loading...
Searching...
No Matches
ConsoleForge.Widgets.TextInput Class Referencesealed

A single-line text input widget that accepts keyboard input when focused. More...

Inheritance diagram for ConsoleForge.Widgets.TextInput:

Public Member Functions

void OnKeyEvent (KeyMsg key, Action< IMsg > dispatch)
 Handle printable char input, Backspace, and Left/Right cursor movement.
void Render (IRenderContext ctx)
 Render this widget into the provided context.The context carries the allocated region, theme, and color profile. Implementations MUST NOT write outside ctx.Region.
 TextInput ()
 Object-initializer constructor; all properties default.
 TextInput (string value="", string placeholder="", int cursorPosition=0, Style? style=null)
 Positional constructor for inline usage.

Properties

int CursorPosition [get]
 Zero-based index of the cursor within Value.
bool HasFocus [get, set]
 True when this widget holds keyboard focus.
SizeConstraint Height = SizeConstraint.Fixed(1) [get]
 Height constraint used by the layout engine.
string Placeholder = "" [get]
 Placeholder text shown when Value is empty.
Style Style = Style.Default [get]
 Visual style for the input text. Inherits theme base style when no properties are set.
string Value = "" [get]
 Current text value in the input field.
SizeConstraint Width = SizeConstraint.Flex(1) [get]
 Width constraint used by the layout engine.

Detailed Description

A single-line text input widget that accepts keyboard input when focused.

Constructor & Destructor Documentation

◆ TextInput()

ConsoleForge.Widgets.TextInput.TextInput ( string value = "",
string placeholder = "",
int cursorPosition = 0,
Style? style = null )

Positional constructor for inline usage.

Parameters
valueInitial text value.
placeholderPlaceholder shown when value is empty.
cursorPositionInitial cursor position (clamped to value length).
styleOptional visual style override.

Member Function Documentation

◆ OnKeyEvent()

void ConsoleForge.Widgets.TextInput.OnKeyEvent ( KeyMsg key,
Action< IMsg > dispatch )

Handle printable char input, Backspace, and Left/Right cursor movement.

NOTE: TextInput is immutable — this method mutates state via HasFocus but keyboard changes are returned as a model message. Callers must update the model's reference to this widget.

Implements ConsoleForge.Layout.IFocusable.


The documentation for this class was generated from the following file:
  • src/ConsoleForge/Widgets/TextInput.cs