TextInput class
#include <Jazz2/UI/Menu/MenuWidgets.h>
Editable text row.
Shows a label with the current text value below it. Activating it (Fire) starts editing (unless read-only or not editable), capturing raw key/text input and showing a blinking caret; Enter commits through OnCommit and Escape cancels. Used for the player name field.
Base classes
- class Widget
- Base class of a menu widget.
Constructors, destructors, conversion operators
-
TextInput(StringView label,
std::
uint32_t maxLength)
Public functions
- auto IsActive() const -> bool
- Returns
truewhile the field is in editing mode. - auto GetText() const -> StringView
- Returns the text currently being edited.
-
auto GetCursor() const -> std::
size_t - Returns the caret position.
- auto GetCaretAnim() const -> float
- Returns the caret blink animation phase.
- void Cancel(IMenuContainer* root)
- Cancels editing without committing.
- void Commit(IMenuContainer* root)
- Commits the current text if non-empty.
- auto GetHeight() const -> float override
- Returns the height the widget occupies in a vertical layout.
- void OnUpdate(float timeMult) override
- Advances the widget's animations.
-
void Draw(IMenuContainer* root,
Canvas* canvas,
const Rectf& bounds,
std::
int32_t& charOffset) override - Draws the widget within the given bounds.
- void Activate(IMenuContainer* root) override
- Called when the widget is activated (e.g., by Fire or a tap).
- auto OnNavigate(const WidgetInput& input, IMenuContainer* root) -> bool override
- Handles navigation input; returns
trueif it was consumed. -
auto OnKeyPressed(const nCine::
KeyboardEvent& event, IMenuContainer* root) -> bool override - Handles a key press while capturing text input; returns
trueif consumed. -
void OnTextInput(const nCine::
TextInputEvent& event) override - Handles a text input event while capturing text input.
- auto IsCapturingInput() const -> bool override
- Returns
truewhile the widget (or a descendant) is capturing raw text input, which restricts navigation. - void OnSelected() override
- Called when the widget becomes selected.
Public variables
- String Label
- Setting label.
- Function<String()> Value
- Returns the value to display when not editing.
- Function<bool()> CanEdit
- Returns
trueif the value can be edited (e.g.,falsewhen overridden by an external account). - Function<bool()> ShowIcon
- Returns
trueif the external-account icon should be drawn next to the value. - Function<void(StringView)> OnCommit
- Invoked with the new text when editing is committed.
- Function<void(bool)> OnEditStateChanged
- Invoked when editing starts (
true) or ends (false), e.g., to manage the on-screen keyboard. - String Icon
- Glyph drawn to the left of the value when ShowIcon returns
true. - bool ReadOnly
- Whether the value is read-only (greyed, not editable).
- float Height
- Height of the item row.
- AnimatedValue Animation
- Selection animation progress.