Field
field · Elements · interactive
A control with its label, its help and its error, laid out as one thing.
Import
cpp
#include "gbui/widgets/field.hpp"Example
cpp
FieldResult field(Ui& ui, const Interaction& input, std::string_view id, const FieldOptions& options, const std::function<void(Ui&)>& control);Draws the caption, then control, then the help or the error.
API
FieldOptions
| Option | Type | Default | What it does |
|---|---|---|---|
label | std::string_view | The caption above the control. Empty draws none, which is what a field inside a table cell or beside its own heading wants. | |
forId | std::string_view | The control this labels, so clicking the caption focuses it. The id of the control built inside the callback — this cannot be worked out from the tree, because the field is built before the control is and a component never reaches into what a caller wrote. | |
help | std::string_view | Guidance under the control. Replaced by error while there is one: advice and a complaint in the same place, at the same time, is two things asking to be read first. | |
error | std::string_view | What is wrong. Non-empty puts the field in its invalid state — the message is drawn in the error colour and the caption goes with it. It does not restyle the control. A component does not reach into another component's options, and a border that changed colour by remote control would be exactly that; pass invalid to the control as well where it has one. What this owns is the message and the caption. | |
required | bool | false | Marks the caption with the usual asterisk. |
disabled | bool | false | |
gap | float | 5.0f | Between the caption, the control and the message. |
width | float | kAuto | |
grow | float | 0.0f |