FormTextFieldWidget
Namespace: Hex1b.Widgets
Assembly: Hex1b.dll
A form text field widget that renders as a label + text input + error indicator. Also serves as a field handle for cross-field references (validation, enablement).
public sealed record FormTextFieldWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<FormTextFieldWidget>Inheritance
Object → Hex1bWidget → FormTextFieldWidget
Implements
Constructors
FormTextFieldWidget(string, string)
Parameters:
public FormTextFieldWidget(string fieldId, string label)Properties
FieldId
Unique identifier for this field within the form. Preserved across fluent method calls.
Returns: String
public string FieldId { get; }InitialValue
Initial text value for the field.
Returns: String
public string? InitialValue { get; init; }Label
The label text displayed for this field.
Returns: String
public string Label { get; init; }MaxWidth
Maximum width of the text input in columns. Defaults to MinWidth if not explicitly set.
Returns: Nullable<Int32>
public int? MaxWidth { get; init; }MinWidth
Minimum width of the text input in columns.
Returns: Nullable<Int32>
public int? MinWidth { get; init; }ValidateOn
When validation should be triggered.
Returns: ValidateOn
public ValidateOn ValidateOn { get; init; }Methods
Adornment(Func<string, CancellationToken, Task<bool>>, Func<Hex1bWidget>)
Adds an adornment with an async predicate and widget builder. The adornment is displayed next to the field when the predicate resolves to true. When the field value changes, the predicate is re-evaluated (cancelling any in-flight evaluation).
Parameters:
predicate(Func<String, CancellationToken, Boolean>>): Async function receiving (fieldValue, cancellationToken) → bool.builder(Func<Hex1bWidget>): Factory returning the widget to display when the predicate is true.
Returns: FormTextFieldWidget
public FormTextFieldWidget Adornment(Func<string, CancellationToken, Task<bool>> predicate, Func<Hex1bWidget> builder)Adornment(Func<string, Task<bool>>, Func<Hex1bWidget>)
Adds an adornment with an async predicate (no cancellation token) and widget builder.
Parameters:
predicate(Func<String, Boolean>>):builder(Func<Hex1bWidget>):
Returns: FormTextFieldWidget
public FormTextFieldWidget Adornment(Func<string, Task<bool>> predicate, Func<Hex1bWidget> builder)EnableWhen(Func<bool>)
Enables this field only when the predicate returns true.
Parameters:
predicate(Func<Boolean>):
Returns: FormTextFieldWidget
public FormTextFieldWidget EnableWhen(Func<bool> predicate)EnableWhenValid(params FormTextFieldWidget[])
Enables this field only when all specified fields are valid.
Parameters:
fields(FormTextFieldWidget[]):
Returns: FormTextFieldWidget
public FormTextFieldWidget EnableWhenValid(params FormTextFieldWidget[] fields)Multiline()
Enables multi-line text editing for this form field.
Returns: FormTextFieldWidget
public FormTextFieldWidget Multiline()Multiline(int)
Enables multi-line text editing with a maximum number of lines. Once the limit is reached, no more newlines can be inserted.
Parameters:
maxLines(Int32):
Returns: FormTextFieldWidget
public FormTextFieldWidget Multiline(int maxLines)OnTextChanged(Action<TextChangedEventArgs>)
Sets a handler for text change events.
Parameters:
handler(Action<TextChangedEventArgs>):
Returns: FormTextFieldWidget
public FormTextFieldWidget OnTextChanged(Action<TextChangedEventArgs> handler)OnTextChanged(Func<TextChangedEventArgs, Task>)
Sets an async handler for text change events.
Parameters:
handler(Func<TextChangedEventArgs, Task>):
Returns: FormTextFieldWidget
public FormTextFieldWidget OnTextChanged(Func<TextChangedEventArgs, Task> handler)Validate(Func<string, ValidationResult>)
Adds a validator to this field.
Parameters:
validator(Func<String, ValidationResult>):
Returns: FormTextFieldWidget
public FormTextFieldWidget Validate(Func<string, ValidationResult> validator)WithHeight(int)
Sets the height of the text input in lines.
Parameters:
lines(Int32):
Returns: FormTextFieldWidget
public FormTextFieldWidget WithHeight(int lines)WithInitialValue(string)
Sets the initial text value.
Parameters:
value(String):
Returns: FormTextFieldWidget
public FormTextFieldWidget WithInitialValue(string value)WithLabelPlacement(LabelPlacement)
Overrides the label placement for this specific field.
Parameters:
placement(LabelPlacement):
Returns: FormTextFieldWidget
public FormTextFieldWidget WithLabelPlacement(LabelPlacement placement)WithMaxWidth(int)
Sets the maximum width of the text input.
Parameters:
width(Int32):
Returns: FormTextFieldWidget
public FormTextFieldWidget WithMaxWidth(int width)WithMinWidth(int)
Sets the minimum width of the text input.
Parameters:
width(Int32):
Returns: FormTextFieldWidget
public FormTextFieldWidget WithMinWidth(int width)WithValidateOn(ValidateOn)
Sets when validation should be triggered for this field.
Parameters:
mode(ValidateOn):
Returns: FormTextFieldWidget
public FormTextFieldWidget WithValidateOn(ValidateOn mode)WithWidth(int)
Sets an exact fixed width for the text input (sets both MinWidth and MaxWidth).
Parameters:
width(Int32):
Returns: FormTextFieldWidget
public FormTextFieldWidget WithWidth(int width)WordWrap()
Enables word wrapping for this multi-line form field.
Returns: FormTextFieldWidget
public FormTextFieldWidget WordWrap()Remarks
FormTextFieldWidget is created via form.TextField("Label") inside a Form builder. It composes a label (TextBlockWidget), a text input (TextBoxWidget), and an optional error indicator into a single self-contained field.
The widget also acts as a field handle: the uniquely identifies this field within the form, enabling cross-field features like .