|
Velvet 0.1a
A beginner-friendly C++ GUI framework built on SFML.
|
Single-line text input widget with placeholder and basic styling. More...
#include <InputField.hpp>
Inheritance diagram for InputField:Public Member Functions | |
| void | render (sf::RenderWindow &window) override |
| Render the input field. | |
| void | setPosition (float x, float y) override |
| Set top-left position of the input box. | |
| void | handleEvent (const sf::Event &event, sf::RenderWindow &window) override |
| Handle focus changes and text input/backspace events. | |
| sf::Vector2f | getDimensions () override |
| Get input field dimensions (container bounds). | |
| InputField (std::string placeholder="", std::unordered_map< std::string, std::variant< unsigned int, float, std::string > > styling={}) | |
| Create an input field with optional placeholder and style overrides. | |
| void | overrideStyling (std::unordered_map< std::string, std::variant< unsigned int, float, std::string > > styling) |
| Apply/override style properties at runtime. | |
| std::string | getContent () |
| Get text content in the field. | |
| std::string | getPlaceholder () |
| Get value of placeholder text . | |
| void | setPlaceholder (std::string placeholderString) |
| Set value of placeholder. | |
Public Member Functions inherited from Widget | |
| Widget () | |
| Construct a widget with default font loading. | |
Additional Inherited Members | |
Public Attributes inherited from Widget | |
| sf::Font | font |
| Shared font loaded by the base widget. | |
Protected Attributes inherited from Widget | |
| float | x |
| float | y |
Single-line text input widget with placeholder and basic styling.
Supported style keys (std::unordered_map<std::string, std::variant<unsigned int, float, std::string>>):
fontPath (std::string)fontSize (float)letterSpacing (float)fontColor (unsigned int) text color, RGBA hex like 0xRRGGBBAAoutlineColor (unsigned int) inactive border coloractiveOutlineColor (unsigned int) active border color when focusedbackgroundColor (unsigned int) input background fillplaceholderColor (unsigned int) color of the placeholder textwidth (float) logical width of the input box | InputField::InputField | ( | std::string | placeholder = "", |
| std::unordered_map< std::string, std::variant< unsigned int, float, std::string > > | styling = {} |
||
| ) |
Create an input field with optional placeholder and style overrides.
| placeholder | Placeholder text to display when empty. |
| styling | Optional style overrides map; unknown keys are ignored with a warning. |
| std::string InputField::getContent | ( | ) |
Get text content in the field.
|
overridevirtual |
Get input field dimensions (container bounds).
Implements Widget.
| std::string InputField::getPlaceholder | ( | ) |
Get value of placeholder text .
|
overridevirtual |
Handle focus changes and text input/backspace events.
Reimplemented from Widget.
| void InputField::overrideStyling | ( | std::unordered_map< std::string, std::variant< unsigned int, float, std::string > > | styling | ) |
Apply/override style properties at runtime.
Unknown keys are ignored with a warning.
|
overridevirtual |
Render the input field.
Reimplemented from Widget.
| void InputField::setPlaceholder | ( | std::string | placeholderString | ) |
Set value of placeholder.
|
overridevirtual |
Set top-left position of the input box.
Implements Widget.