class TUI::Form::FormFieldCell(M)

Overview

One form row as its own composited Widget: a label plus whichever FormField edit session field.build constructs (or, for a dropdown_options field, a TUI::DropdownPicker popup pushed through popup instead — see #start_editing). Grid (src/tui/layout/grid.cr) positions and focuses one of these per field; Form::Host builds one FormFieldCell per FieldSpec and attaches them into its internal Grid, rather than looping over @fields and hand-computing row/column coordinates itself the way it used to.

field.get/field.set are the only way this class reads or writes @model — a FieldSpec cannot exist without both, so every cell rendered or committed here is guaranteed to be backed by a real accessor on M, never a value invented independently of the model. This mirrors the invariant Form::Host itself used to state.

Defined in:

tui/form/form_field_cell.cr

Constant Summary

DEFAULT_MAX_ERROR_WIDTH = 40
DEFAULT_MIN_VALUE_WIDTH = 20

Constructors

Instance Method Summary

Instance methods inherited from class TUI::Widget

absolute(row : Int32, col : Int32) : NamedTuple(row: Int32, col: Int32) absolute, composite(screen : Screen) : Nil composite, focus_if(condition : Bool) : Nil focus_if, focused=(focused : Bool) focused=, focused? : Bool focused?, handle_key(ev : KeyEvent) : Bool handle_key, height : Int32 height, height=(height : Int32) height=, local(row : Int32, col : Int32) : NamedTuple(row: Int32, col: Int32) local, render : Nil render, render_to(buffer : Buffer) : Nil render_to, status_hint : String status_hint, width : Int32 width, width=(width : Int32) width=, x : Int32 x, x=(x : Int32) x=, y : Int32 y, y=(y : Int32) y=

Constructor methods inherited from class TUI::Widget

new(x : Int32, y : Int32, width : Int32, height : Int32) new

Constructor Detail

def self.new(x : Int32, y : Int32, width : Int32, height : Int32, field : FieldSpec(M), model : M, popup : PopupHost, label_width : Int32, min_value_width : Int32 = DEFAULT_MIN_VALUE_WIDTH, max_error_width : Int32 = DEFAULT_MAX_ERROR_WIDTH) #

[View source]

Instance Method Detail

def error_style : Style #

[View source]
def error_style=(error_style : Style) #

[View source]
def handle_key(ev : KeyEvent) : Bool #
Description copied from class TUI::Widget

Returns true if the key was consumed.


[View source]
def label_error_style : Style #

[View source]
def label_error_style=(label_error_style : Style) #

[View source]
def label_style : Style #

[View source]
def label_style=(label_style : Style) #

[View source]
def popup_border_style : Style #

Applied to a dropdown popup's own border when this cell opens one (see #open_dropdown) — passed in from Form::Host's own border_style so a dropdown popup visually matches the form it was opened from, the same styling Form::Host applied directly before this logic moved into FormFieldCell.


[View source]
def popup_border_style=(popup_border_style : Style) #

Applied to a dropdown popup's own border when this cell opens one (see #open_dropdown) — passed in from Form::Host's own border_style so a dropdown popup visually matches the form it was opened from, the same styling Form::Host applied directly before this logic moved into FormFieldCell.


[View source]
def render : Nil #
Description copied from class TUI::Widget

Draw into @buffer using LOCAL coordinates (0, 0 = this widget's own top-left). Widgets never need to know their own x/y offset to draw themselves — that arithmetic is handled entirely by composite.


[View source]
def status_hint : String #
Description copied from class TUI::Widget

Plain text describing the actions available in the widget's current state. Rendered by the App in the global status bar at the bottom of the screen — widgets must NOT draw their own hint lines.


[View source]