Form class
Namespace: Arlecchino.Forms · Assembly: Arlecchino
A column of fields with their values lined up, and a help line under the selected one. It holds no values of its own, and the atom behind each field decides whether an edit can be undone.
public sealed class Form : IArlecchinoInteractiveWidget, IArlecchinoWidget, IArlecchinoFocusable
Implements IArlecchinoInteractiveWidget, IArlecchinoWidget, IArlecchinoFocusable
Constructors
| Member | Summary |
|---|---|
Form(ArlecchinoState, ArlecchinoOptions) | Creates the form. |
Properties
| Member | Summary |
|---|---|
Current | The selected field, or null when the form has none. |
Fields | The rows, top to bottom. |
IsFocused | Whether the form has focus, which decides how strongly the selection is drawn. |
SelectedIndex | Index of the selected field. |
Methods
| Member | Summary |
|---|---|
Draw(SurfaceRegion) | Draws the fields with their labels aligned, scrolled, so the selection stays in view, and returns the rows below the last one written. Buttons are left out of the alignment, since they have no value to line up against. |
Handle(KeyPress) | Moves through the fields, opens one, or clears it. For a view that is nothing but a form; views that mix a form with other panes hand it to the focus ring instead. |
HandleMouse(MouseEvent) | Scrolls with the wheel and selects with a click. Clicking the already selected field opens it, so a double click reads as select-then-edit. |
Hints() | What the form does with keys, worded and bound as the application configured it, ready to be shown in the hint line. |
Constructors in detail
Form(ArlecchinoState, ArlecchinoOptions)
Constructors of types with required members are not supported in this version of your compiler.
public Form(ArlecchinoState state, ArlecchinoOptions options);
Creates the form.
Parameters
| Name | Type | Description |
|---|---|---|
state | ArlecchinoState | Where fields open their dialogs. |
options | ArlecchinoOptions | Supplies the keymap and the wording. |
Properties in detail
Current
public Field? Current { get; }
The selected field, or null when the form has none.
Type Field
Fields
public IReadOnlyList<Field> Fields { get; init; }
The rows, top to bottom.
Type IReadOnlyList<T><Field>
IsFocused
public bool IsFocused { get; set; }
Whether the form has focus, which decides how strongly the selection is drawn.
Type bool
SelectedIndex
public int SelectedIndex { get; }
Index of the selected field.
Type int
Methods in detail
Draw(SurfaceRegion)
public SurfaceRegion Draw(SurfaceRegion region);
Draws the fields with their labels aligned, scrolled, so the selection stays in view, and returns the rows below the last one written. Buttons are left out of the alignment, since they have no value to line up against.
Parameters
| Name | Type | Description |
|---|---|---|
region | SurfaceRegion | Where to draw, help line included. |
Returns SurfaceRegion — The region below the fields, which is empty when they filled it.
Handle(KeyPress)
public FocusResult Handle(KeyPress key);
Moves through the fields, opens one, or clears it. For a view that is nothing but a form; views that mix a form with other panes hand it to the focus ring instead.
Parameters
| Name | Type | Description |
|---|---|---|
key | KeyPress | The key that was pressed. |
Returns FocusResult — What was done with it, and where to go.
HandleMouse(MouseEvent)
public FocusResult HandleMouse(MouseEvent mouse);
Scrolls with the wheel and selects with a click. Clicking the already selected field opens it, so a double click reads as select-then-edit.
Parameters
| Name | Type | Description |
|---|---|---|
mouse | MouseEvent | The event that arrived. |
Returns FocusResult — What was done with it, and where to go.
Hints()
public ValueTuple<string, string>[] Hints();
What the form does with keys, worded and bound as the application configured it, ready to be shown in the hint line.
Returns ValueTuple<T1, T2><string, string>[] — The key and its description, one pair per action.