GGUI/Public/UIText.h file

Text widgets: editable and selectable text.

ui.TextField({ .Placeholder = "Player name" }, name, OnCommit([](std::string_view text) { SetName(text); }));
ui.TextField({ .Accepts = TextAccepts::Digits, .MaxLength = 5 }, portText, [](std::string_view text) { ... });
ui.TextArea({ .Height = GGSize::Fixed(120) }, notes);        // a TextBuffer the caller owns
ui.Label("Build 1.2.3", { .bSelectable = true });

Like every value widget: what it shows, then what an edit does.

It shows either

text          The field keeps its own copy. The caller hears about edits through the second
              argument. If the text passed in differs from last time, the field takes it.
a TextBuffer  The field edits the caller's buffer in place, undo history included. Edits
              made elsewhere show up immediately. The buffer must outlive the UI. The second
              argument is optional.

The second argument is one of

[](std::string_view text) { ... }             every change
OnCommit([](std::string_view text) { ... })   Enter, or focus leaving
GGEdits<std::string_view>{ ... }              all phases; Cancel (Escape) restores the text
                                              the edit started from

Standard editing keys, word movement with Ctrl, double-click selects a word, triple-click a line. Tab moves focus unless the area sets bTabInserts. IME composition is shown inline.

Namespaces

namespace GGUI
namespace GGUI::TextFields
Text widgets as they are, for tools, tests, and other widgets.

Classes

class GGUI::ShowsText
What a text widget shows: plain text or a TextBuffer.
struct GGUI::TextFieldProps
Properties of ui.TextField: one line of editable text.
struct GGUI::SearchFieldProps
Properties of ui.SearchField: one line with a clear button.
struct GGUI::TextAreaProps
Properties of ui.TextArea: several lines of text, scrolling when they don't fit.