38 const std::string &
getText()
const {
return text; }
56 const std::string &getCompositionText() const noexcept {
return compositionText_; }
57 int getCompositionCursor() const noexcept {
return compositionCursor_; }
58 bool isComposing() const noexcept {
return !compositionText_.empty(); }
66 std::function<void(
const std::string &)>
onSubmit;
68 static constexpr const char *PART_SELECTION =
"selection";
69 static constexpr const char *PART_PLACEHOLDER =
"placeholder";
70 static constexpr const char *PART_CURSOR =
"cursor";
80 int cursorIndexFromX(
float localX);
87 std::deque<HistoryState> undoStack;
88 std::deque<HistoryState> redoStack;
93 void selectWordAtCursor();
96 std::string placeholder;
97 bool placeholderWrap{
false};
99 int selectionStart{-1};
100 std::string compositionText_;
101 int compositionCursor_{0};
102 int compositionSelLen_{0};
103 bool hasFocusCache{
false};
104 float cursorBlink{0.0f};
106 FontHandle defaultFont{0};
109 double lastClickTime{0.0};
113 float holdTime{0.0f};
114 float nextFireTime{0.0f};
116 std::unordered_map<int, RepeatState> repeatStates;
Centralized standard library includes used throughout ZenitUI.
The node class: tree structure, layout pass, style resolution, input dispatch, render orchestration,...
TLayout(Args &&...args)
Definition Layout.hpp:1401
void onUpdate(float dt) override
Called every frame from update, after input dispatch.
const std::string & getText() const
Current content.
Definition TextInput.hpp:38
void onEnabledChanged(bool nowEnabled) override
Called from setEnabled after the state change.
void setText(std::string t)
Replace the content, snap cursor to a valid UTF-8 boundary, clear selection, and save undo history.
void renderContent(float op, const ComputedStyle &style) override
Draw the node's content (text, images, custom geometry).
TextInput(std::string initial="")
Construct with initial text.
std::function< void(const std::string &)> onTextChanged
Fired on every content change (typing, paste, delete, cut, undo, redo).
Definition TextInput.hpp:64
void clear()
Reset to empty content.
Definition TextInput.hpp:40
bool getPlaceholderWrap() const
true if placeholder wrapping is enabled.
Definition TextInput.hpp:49
std::function< void(const std::string &)> onSubmit
Fired on Enter; the field loses focus immediately after.
Definition TextInput.hpp:66
void setPlaceholder(std::string p)
Placeholder shown when body is empty.
void setCursorPos(int pos)
Move the cursor (clamped and snapped to a valid UTF-8 boundary); clears selection.
Vec2 computeIntrinsicSize(float availW, float availH) override
Compute the intrinsic size, excluding padding and border.
void setFont(FontHandle f)
Override the font used for measurement and rendering.
const std::string & getPlaceholder() const
Current placeholder text.
Definition TextInput.hpp:45
int getCursorPos() const
Current cursor position in bytes from the start.
Definition TextInput.hpp:52
void setPlaceholderWrap(bool w)
Enable or disable multi-line wrapping for the placeholder.
Dense style: every property has a concrete value.
Definition Style.hpp:1036
Opaque handle to a font loaded by TextEngine.
Definition CoreTypes.hpp:135
Typographic parameters governing shaping and measurement.
Definition TextEngine.hpp:51
2D vector with component-wise arithmetic.
Definition CoreTypes.hpp:25