A UI text input field component.
More...
#include <Textbox.h>
|
| Textbox ()=default |
| Default constructor (for serialization).
|
|
| Textbox (const Textbox &)=delete |
|
Textbox & | operator= (const Textbox &)=delete |
|
| Textbox (const std::string &textureKey, const std::string &fontKey, float width, float height) |
| Constructs a Textbox with specified texture key, font key, width, and height.
|
|
void | SetPosition (float x, float y) |
| Sets the text label of the textbox.
|
|
void | SetScale (float x, float y) |
| Sets the scale of the textbox.
|
|
void | SetLayer (int layer) override |
| Sets the rendering layer of the textbox.
|
|
const std::string & | GetText () const |
| Gets the current text in the textbox.
|
|
void | LoseFocus () |
| Removes focus from the textbox (stops receiving keyboard input).
|
|
char | GetCharFromKey (AZUL_KEY key, bool shiftHeld) |
| Sets the focus to the textbox (starts receiving keyboard input).
|
|
void | ClearText () |
| Clears the current text in the textbox.
|
|
void | SetCharacterLimit (int limit) |
| Sets the maximum number of characters allowed in the textbox.
|
|
void | SetTextSize (float x, float y) |
| Sets the size of the text in the textbox.
|
|
void | SetTextSizePixel (float x, float y) |
| Sets the size of the text in the textbox by pixel dimensions.
|
|
virtual | ~UIComponent ()=default |
| Virtual destructor.
|
|
int | GetLayer () const |
| Gets the rendering layer of the component.
|
|
UIComponentType | GetType () const |
| Gets the type of the UI component.
|
|
bool | IsEnabled () const |
| Returns whether the component is enabled or not.
|
|
void | SetEnabled (bool enabled) |
| Sets the enabled state of the component.
|
|
void | SetOwningCanvas (Canvas *canvas) |
| Gets the owning canvas of the component.
|
|
|
void | KeyPress (AZUL_KEY key) override |
| Handles key press events for text input and editing.
|
|
void | KeyHeld (AZUL_KEY key) override |
| Handles key held events for text input and editing.
|
|
void | KeyRelease (AZUL_KEY key) override |
| Handles key release events.
|
|
void | Render () override |
| Renders the textbox background and text label.
|
|
bool | IsMouseOver (float x, float y) override |
| Checks if the mouse is over the textbox.
|
|
void | OnPress () override |
| Handles mouse press events (focuses the textbox).
|
|
void | UpdateTextLabel () |
| Updates the world matrix of the textbox.
|
|
void | KeyboardReg () |
| Handles registration when the textbox is focused.
|
|
void | KeyboardDereg () |
| Handles deregistration when the textbox is unfocused.
|
|
|
SUNENGINESprite * | pBackgroundSprite |
| Background sprite for the textbox.
|
|
SpriteString * | pTextLabel |
| Text label for displaying input.
|
|
std::string | text |
| Current text in the textbox.
|
|
std::string | fontKey |
| Font key for the text label.
|
|
float | posX |
| X position of the textbox center.
|
|
float | posY |
| Y position of the textbox center.
|
|
float | width |
| Width of the textbox.
|
|
float | height |
| Height of the textbox.
|
|
float | scaleX |
| X scale factor.
|
|
float | scaleY |
| Y scale factor.
|
|
bool | isFocused |
| True if the textbox is focused for input.
|
|
bool | shiftHeld |
| True if shift is currently held.
|
|
bool | capsLock |
| True if caps lock is active.
|
|
int | characterLimit |
| Maximum number of characters allowed in the textbox.
|
|
A UI text input field component.
The Textbox class provides a user interface element for text input. It supports mouse and keyboard interaction, including focus management, character input, and text editing. The textbox displays a background sprite and a text label, and can be positioned and scaled. It inherits from both UIComponent and Inputable to handle rendering and input events.
Example usage:
Textbox* textbox =
new Textbox(
"TextboxBG",
"Courier_New", 300.0f, 100.0f);
canvas->AddComponent(textbox);
void SetScale(float x, float y)
Sets the scale of the textbox.
Definition Textbox.cpp:46
void SetPosition(float x, float y)
Sets the text label of the textbox.
Definition Textbox.cpp:38
Textbox()=default
Default constructor (for serialization).
- See also
- Canvas, SpriteString, Inputable
◆ Textbox()
Textbox::Textbox |
( |
const std::string & | textureKey, |
|
|
const std::string & | fontKey, |
|
|
float | width, |
|
|
float | height ) |
Constructs a Textbox with specified texture key, font key, width, and height.
- Parameters
-
textureKey | The texture key for the background sprite. |
fontKey | The font key for the text label. |
width | The width of the textbox in pixels. |
height | The height of the textbox in pixels. |
◆ GetText()
const std::string & Textbox::GetText |
( |
| ) |
const |
Gets the current text in the textbox.
- Returns
- The current text string.
◆ IsMouseOver()
bool Textbox::IsMouseOver |
( |
float | x, |
|
|
float | y ) |
|
overrideprivatevirtual |
Checks if the mouse is over the textbox.
- Parameters
-
x | The x-coordinate of the mouse. |
y | The y-coordinate of the mouse. |
- Returns
- True if the mouse is over the textbox, false otherwise.
Implements UIComponent.
◆ KeyHeld()
void Textbox::KeyHeld |
( |
AZUL_KEY | key | ) |
|
|
overrideprivatevirtual |
Handles key held events for text input and editing.
- Parameters
-
key | The key that is being held. |
Reimplemented from Inputable.
◆ KeyPress()
void Textbox::KeyPress |
( |
AZUL_KEY | key | ) |
|
|
overrideprivatevirtual |
Handles key press events for text input and editing.
- Parameters
-
key | The key that was pressed. |
Reimplemented from Inputable.
◆ KeyRelease()
void Textbox::KeyRelease |
( |
AZUL_KEY | key | ) |
|
|
overrideprivatevirtual |
Handles key release events.
- Parameters
-
key | The key that was released. |
Reimplemented from Inputable.
◆ OnPress()
void Textbox::OnPress |
( |
| ) |
|
|
overrideprivatevirtual |
Handles mouse press events (focuses the textbox).
Implements UIComponent.
◆ Render()
Renders the textbox background and text label.
Implements UIComponent.
◆ SetCharacterLimit()
void Textbox::SetCharacterLimit |
( |
int | limit | ) |
|
Sets the maximum number of characters allowed in the textbox.
- Parameters
-
limit | The character limit. |
◆ SetLayer()
void Textbox::SetLayer |
( |
int | layer | ) |
|
|
overridevirtual |
Sets the rendering layer of the textbox.
- Parameters
-
Reimplemented from UIComponent.
◆ SetPosition()
void Textbox::SetPosition |
( |
float | x, |
|
|
float | y ) |
Sets the text label of the textbox.
- Parameters
-
text | The text to display in the textbox. |
◆ SetScale()
void Textbox::SetScale |
( |
float | x, |
|
|
float | y ) |
Sets the scale of the textbox.
- Parameters
-
x | The x-scale factor. |
y | The y-scale factor. |
◆ SetTextSize()
void Textbox::SetTextSize |
( |
float | x, |
|
|
float | y ) |
Sets the size of the text in the textbox.
- Parameters
-
x | The x-scale factor for the text. |
y | The y-scale factor for the text. |
◆ SetTextSizePixel()
void Textbox::SetTextSizePixel |
( |
float | x, |
|
|
float | y ) |
Sets the size of the text in the textbox by pixel dimensions.
- Parameters
-
x | The x-scale in pixels for the text. |
y | The y-scale in pixels for the text. |
The documentation for this class was generated from the following files: