|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
The texts around the input of a text field, and its error state: placeholder, label, supporting text, prefix, suffix and error text. More...
#include <headers/guillaume/components/text_field.hpp>


Public Member Functions | |
| TextField (void)=default | |
| Create a field with no text and no error. | |
| ~TextField (void)=default | |
| Default destructor. | |
| const std::string & | getPlaceholder (void) const |
| Get the placeholder: the text that names the field. | |
| TextField & | setPlaceholder (const std::string &placeholder) |
| Set the placeholder: the text that names the field, such as "Email". | |
| const std::string & | getLabel (void) const |
| Get the label. | |
| TextField & | setLabel (const std::string &label) |
| Store the label. | |
| const std::string & | getSupportingText (void) const |
| Get the helper text shown under the field. | |
| TextField & | setSupportingText (const std::string &supportingText) |
| Set the helper text shown under the field, such as "At
least 8 characters". | |
| const std::string & | getPrefix (void) const |
| Get the fixed text shown before the input. | |
| TextField & | setPrefix (const std::string &prefix) |
| Set the fixed text shown before the input, such as "$". | |
| const std::string & | getSuffix (void) const |
| Get the fixed text shown after the input. | |
| TextField & | setSuffix (const std::string &suffix) |
| Set the fixed text shown after the input, such as "kg". | |
| const std::string & | getErrorText (void) const |
| Get the message shown under the field while it is in error. | |
| TextField & | setErrorText (const std::string &errorText) |
| Set the message shown under the field while it is in error. | |
| bool | isError (void) const |
| Tell whether the field is in error. | |
| TextField & | setError (bool error) |
| Put the field in error or clear the error. | |
| bool | isLabelFloating (void) const |
| Tell whether the label is drawn small, above the input. | |
| TextField & | setLabelFloating (bool floating) |
| Store whether the label floats above the input. | |
| Public Member Functions inherited from guillaume::ecs::Component | |
| bool | hasChanged (void) const |
| Tell whether a value of the component changed since the flags were last reset (the end of the previous frame). | |
| void | setHasChanged (bool hasChanged) |
| Raise or lower the changed flag. | |
| Component (void)=default | |
| Create a component that is not marked as changed. | |
| virtual | ~Component (void)=default |
| Virtual destructor, so components can be destroyed through the base class. | |
The texts around the input of a text field, and its error state: placeholder, label, supporting text, prefix, suffix and error text.
It is shared by the two widgets that contain an input: entities::TextField (together with components::TextFieldConfiguration) and entities::Search. The widget writes the texts and the error flag. systems::TextField reads them in the Layout phase to fill and color the label, affix and supporting text children.
Two members are derived, not chosen: systems::TextField and systems::Search overwrite the label with the placeholder, and the label-floating flag with the state of the field, every frame. The text the user types is not stored here; it is the components::Text of the input.
Definition at line 52 of file text_field.hpp.
| const std::string & guillaume::components::TextField::getErrorText | ( | void | ) | const |
Get the message shown under the field while it is in error.
Definition at line 102 of file text_field.cpp.

| const std::string & guillaume::components::TextField::getLabel | ( | void | ) | const |
Get the label.
Definition at line 42 of file text_field.cpp.
| const std::string & guillaume::components::TextField::getPlaceholder | ( | void | ) | const |
Get the placeholder: the text that names the field.
Definition at line 27 of file text_field.cpp.
| const std::string & guillaume::components::TextField::getPrefix | ( | void | ) | const |
Get the fixed text shown before the input.
Definition at line 72 of file text_field.cpp.
| const std::string & guillaume::components::TextField::getSuffix | ( | void | ) | const |
Get the fixed text shown after the input.
Definition at line 87 of file text_field.cpp.
| const std::string & guillaume::components::TextField::getSupportingText | ( | void | ) | const |
Get the helper text shown under the field.
Definition at line 57 of file text_field.cpp.
| bool guillaume::components::TextField::isError | ( | void | ) | const |
Tell whether the field is in error.
Definition at line 117 of file text_field.cpp.

| bool guillaume::components::TextField::isLabelFloating | ( | void | ) | const |
Tell whether the label is drawn small, above the input.
Definition at line 132 of file text_field.cpp.
| TextField & guillaume::components::TextField::setError | ( | bool | error | ) |
Put the field in error or clear the error.
A field in error is drawn with the error colors, shows its error icon in place of the trailing icon and its error text in place of the supporting text. Marks the component changed only when the flag differs.
| error | True when the content is invalid. |
Definition at line 122 of file text_field.cpp.

| TextField & guillaume::components::TextField::setErrorText | ( | const std::string & | errorText | ) |
Set the message shown under the field while it is in error.
It replaces the supporting text only while isError() is true. Marks the component changed only when the text differs.
| errorText | The new error text. |
Definition at line 107 of file text_field.cpp.

| TextField & guillaume::components::TextField::setLabel | ( | const std::string & | label | ) |
Store the label.
systems::TextField and systems::Search overwrite it with the placeholder every frame, so set the placeholder instead. Marks the component changed only when the text differs.
| label | The new label. |
Definition at line 47 of file text_field.cpp.


| TextField & guillaume::components::TextField::setLabelFloating | ( | bool | floating | ) |
Store whether the label floats above the input.
The systems overwrite it every frame: the label of a text field widget floats while the field is focused or has content; the label of any other entity with this component floats while it has content or is in error. Marks the component changed only when the flag differs.
| floating | True when the label floats. |
Definition at line 137 of file text_field.cpp.


| TextField & guillaume::components::TextField::setPlaceholder | ( | const std::string & | placeholder | ) |
Set the placeholder: the text that names the field, such as "Email".
It is drawn by the label child, inside the field while it is empty and above the input once it floats. Marks the component changed only when the text differs.
| placeholder | The new placeholder. |
Definition at line 32 of file text_field.cpp.


| TextField & guillaume::components::TextField::setPrefix | ( | const std::string & | prefix | ) |
Set the fixed text shown before the input, such as "$".
Marks the component changed only when the text differs.
| prefix | The new prefix. |
Definition at line 77 of file text_field.cpp.

| TextField & guillaume::components::TextField::setSuffix | ( | const std::string & | suffix | ) |
Set the fixed text shown after the input, such as "kg".
Marks the component changed only when the text differs.
| suffix | The new suffix. |
Definition at line 92 of file text_field.cpp.

| TextField & guillaume::components::TextField::setSupportingText | ( | const std::string & | supportingText | ) |
Set the helper text shown under the field, such as "At least 8 characters".
While the field is in error and has an error text, the error text is shown in its place. Marks the component changed only when the text differs.
| supportingText | The new supporting text. |
Definition at line 62 of file text_field.cpp.
