Package com.tonic.vellum.widget
Class Form
- java.lang.Object
-
- com.tonic.vellum.Section
-
- com.tonic.vellum.layout.Split
-
- com.tonic.vellum.widget.Form
-
- All Implemented Interfaces:
FocusContainer
public final class Form extends Split implements FocusContainer
A stack of fields with internal Tab traversal: Tab and Shift-Tab cycle the fields, descending depth-first into nested forms. ESC fires the cancel handler.
-
-
Constructor Summary
Constructors Constructor Description Form()Creates a vertical form whose fields are stacked top to bottom.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SectionactiveFocusTarget()Returns the currently focused internal target.FormaddField(Section field)Adds a focusable field spanning one cell along the form's axis.FormaddField(Section field, int size)Adds a focusable field spanning a fixed number of cells along the form's axis.FormaddField(Section field, Constraint size)Adds a focusable field sized by an explicit layout constraint.FormaddStatic(Section decoration, int size)Adds non-focusable decoration (such as a label) spanning a fixed number of cells.booleanadvanceFocus(boolean forward)Moves internal focus in the given direction.java.util.List<Section>focusTargets()Returns the focusable descendants this container manages internally.FormonCancel(java.lang.Runnable handler)Sets the handler run when ESC is pressed while the form has focus.static Formrow()-
Methods inherited from class com.tonic.vellum.layout.Split
add, horizontal, vertical
-
-
-
-
Method Detail
-
row
public static Form row()
- Returns:
- a new horizontal form, fields laid out left to right
-
addField
public Form addField(Section field)
Adds a focusable field spanning one cell along the form's axis.- Parameters:
field- the field to add- Returns:
- this Form for chaining
-
addField
public Form addField(Section field, int size)
Adds a focusable field spanning a fixed number of cells along the form's axis.- Parameters:
field- the field to addsize- the number of cells to span- Returns:
- this Form for chaining
-
addField
public Form addField(Section field, Constraint size)
Adds a focusable field sized by an explicit layout constraint.- Parameters:
field- the field to addsize- the constraint sizing the field along the form's axis- Returns:
- this Form for chaining
-
addStatic
public Form addStatic(Section decoration, int size)
Adds non-focusable decoration (such as a label) spanning a fixed number of cells.- Parameters:
decoration- the section to addsize- the number of cells to span- Returns:
- this Form for chaining
-
onCancel
public Form onCancel(java.lang.Runnable handler)
Sets the handler run when ESC is pressed while the form has focus.- Parameters:
handler- the cancel handler- Returns:
- this Form for chaining
-
focusTargets
public java.util.List<Section> focusTargets()
Description copied from interface:FocusContainerReturns the focusable descendants this container manages internally.- Specified by:
focusTargetsin interfaceFocusContainer- Returns:
- the focus targets, in traversal order
-
activeFocusTarget
public Section activeFocusTarget()
Description copied from interface:FocusContainerReturns the currently focused internal target.- Specified by:
activeFocusTargetin interfaceFocusContainer- Returns:
- the active focus target, or
nullwhen none is focused
-
advanceFocus
public boolean advanceFocus(boolean forward)
Description copied from interface:FocusContainerMoves internal focus in the given direction.- Specified by:
advanceFocusin interfaceFocusContainer- Parameters:
forward- true to advance, false to move back- Returns:
- true when focus moved internally, false at an edge so the parent advances instead
-
-