Editable single-line text input field.
More...
#include <inputfield_component.hpp>
|
| void | draw (double dt) |
| | Draws the field background, border, text and caret.
|
| |
|
| float | blinkTimer = 0 |
| | Accumulator driving the caret blink.
|
| |
| size_t | eventHandlerID |
| | Id of the registered character-event handler.
|
| |
| size_t | keyEventHandlerID |
| | Id of the registered key-event handler.
|
| |
| size_t | startIdx |
| | Index of the first visible character (horizontal scroll).
|
| |
| Transform * | t |
| | Cached transform of the owning object.
|
| |
| QuadRenderer * | qr |
| | Renderer used to draw border/caret.
|
| |
|
| TextRenderer * | tr |
| | Renderer used to draw the text.
|
| |
| std::string | path |
| | Path of the loaded font file.
|
| |
| int | fontHeight |
| | Pixel height the font is loaded at.
|
| |
| Font * | font = nullptr |
| | Loaded font, or nullptr.
|
| |
| Texture * | backTex = nullptr |
| | Optional background texture.
|
| |
Editable single-line text input field.
Extends TextRendererComponent to capture keyboard/character input, maintain a caret and content string, scroll the visible text, and fire a callback when Enter is pressed. Only one field is focused at a time.
◆ InputFieldComponent()
| cangine::InputFieldComponent::InputFieldComponent |
( |
| ) |
|
◆ ~InputFieldComponent()
| cangine::InputFieldComponent::~InputFieldComponent |
( |
| ) |
|
◆ draw()
| void cangine::InputFieldComponent::draw |
( |
double |
dt | ) |
|
|
private |
Draws the field background, border, text and caret.
- Parameters
-
| dt | Seconds elapsed since the previous frame. |
◆ firstFrame()
| void cangine::InputFieldComponent::firstFrame |
( |
| ) |
|
|
overridevirtual |
◆ frame()
| void cangine::InputFieldComponent::frame |
( |
double |
deltaTime | ) |
|
|
overridevirtual |
Called every frame to update the component.
- Parameters
-
| deltaTime | Seconds elapsed since the previous frame. |
Reimplemented from cangine::IComponent.
◆ inputEventHandler()
| void cangine::InputFieldComponent::inputEventHandler |
( |
std::string |
s | ) |
|
Inserts typed characters at the caret.
- Parameters
-
| s | UTF-8 text that was typed. |
◆ keyEventHandler()
| void cangine::InputFieldComponent::keyEventHandler |
( |
KeyEvent |
event | ) |
|
Handles editing keys (arrows, backspace, enter, ...).
- Parameters
-
◆ onMouseEvent()
| void cangine::InputFieldComponent::onMouseEvent |
( |
const MouseEvent * |
e | ) |
|
|
overridevirtual |
Called when a mouse event is dispatched to the owning object.
- Parameters
-
Reimplemented from cangine::IComponent.
◆ updateView()
| void cangine::InputFieldComponent::updateView |
( |
| ) |
|
Recomputes the visible text window from the caret position.
◆ blinkTimer
| float cangine::InputFieldComponent::blinkTimer = 0 |
|
private |
Accumulator driving the caret blink.
◆ borderColor
| Color cangine::InputFieldComponent::borderColor |
Border color when not focused.
◆ borderColorFocus
| Color cangine::InputFieldComponent::borderColorFocus |
Border color when focused.
◆ borderWidth
| float cangine::InputFieldComponent::borderWidth |
Border thickness in pixels.
◆ content
| std::string cangine::InputFieldComponent::content |
◆ cursorColor
| Color cangine::InputFieldComponent::cursorColor |
◆ cursorpos
| int cangine::InputFieldComponent::cursorpos = 0 |
Caret position as an index into content.
◆ eventHandlerID
| size_t cangine::InputFieldComponent::eventHandlerID |
|
private |
Id of the registered character-event handler.
◆ focused
The currently focused field, or nullptr.
◆ height
| int cangine::InputFieldComponent::height = 25 |
◆ keyEventHandlerID
| size_t cangine::InputFieldComponent::keyEventHandlerID |
|
private |
Id of the registered key-event handler.
◆ onReturn
| std::function<void(std::string)> cangine::InputFieldComponent::onReturn = nullptr |
Called with the content when Enter is pressed.
◆ placeholder
| std::string cangine::InputFieldComponent::placeholder |
Text shown when the field is empty.
◆ placeholderColor
| Color cangine::InputFieldComponent::placeholderColor |
Color of the placeholder text.
◆ qr
Renderer used to draw border/caret.
◆ startIdx
| size_t cangine::InputFieldComponent::startIdx |
|
private |
Index of the first visible character (horizontal scroll).
Cached transform of the owning object.
◆ width
| int cangine::InputFieldComponent::width = 128 |
The documentation for this class was generated from the following files: