TextInputBuffer class
#include <Jazz2/UI/Menu/TextInputBuffer.h>
Helper class that manages text editing state for text input fields.
Holds the current text, cursor position, and caret blink animation for an editable field, and translates keyboard and text input events into edits. Reused by menu sections that need text entry.
Constructors, destructors, conversion operators
-
TextInputBuffer(std::
uint32_t maxLength = UINT32_MAX) explicit - Creates a new instance with the specified maximum text length.
Public functions
- auto IsActive() const -> bool
- Returns
trueif the buffer is currently accepting input. - void Activate(StringView initialText = {})
- Activates the buffer, optionally seeding it with the specified text.
- void Deactivate()
- Deactivates the buffer.
- auto GetText() const -> StringView
- Returns the current text.
-
auto GetCursor() const -> std::
size_t - Returns the current cursor position.
- auto GetCaretAnim() const -> float
- Returns the current caret blink animation phase.
- void Update(float timeMult)
- Advances the caret blink animation.
-
auto OnKeyPressed(const nCine::
KeyboardEvent& event) -> bool - Handles editing keys (Backspace, Delete, arrow keys, Home, End).
-
auto OnTextInput(const nCine::
TextInputEvent& event) -> bool - Inserts text at the current cursor position.
Function documentation
bool Jazz2:: UI:: Menu:: TextInputBuffer:: OnKeyPressed(const nCine:: KeyboardEvent& event)
Handles editing keys (Backspace, Delete, arrow keys, Home, End).
| Returns | true if the event was consumed. |
|---|
bool Jazz2:: UI:: Menu:: TextInputBuffer:: OnTextInput(const nCine:: TextInputEvent& event)
Inserts text at the current cursor position.
| Returns | true if the text was inserted. |
|---|