Skip to content

TextInput

TechnologicalTurtle edited this page Jul 21, 2026 · 13 revisions

TextInput

Wrapper for LibGui::DynamicText, that adds text editing.

Initialization

// load font
LibGui::DT_TextureAtlas roboto("roboto.ttf");

// initialize textinput
LibGui::TextInput MyInput(roboto);
// or initialize textinput with window
LibGui::TextInput MyInput(MyWindow, roboto);

// its good to set some properties
MyInput.minSize = {100, 64};

Usage

First initialize the text input, then just Update() it in while loop.

// initialize textinput
LibGui::TextInput MyInput(MyWindow, roboto);

// its good to set some properties
MyInput.minSize = {100, 64};

while (!MyWindow.ShouldClose())
{
   MyWindow.Draw();

   MyInput.Update();

   MyWindow.PushDraw();
}

Methods

void Update(bool render_afterwards)

Updates input, if render_afterwards is true, it calls Render() to render.

void Render()

Renders TextInput.

bool Rect_OnMouseEnter(Vec2 anchor)

Returns if user mouse is on TextInput. Ignore anchor parameter, as the function is override for RectangleInput::Rect_OnMouseEnter().

Properties

Type Name Description
bool active Can user interact with TextInput?
string text Text in this TextInput
function pointer string(*preprocessText)(const string&) Pointer to function that can process text before rendering. (useful f. e. for syntax highlighting)
float fontSize Text input's text size
Vec2 minSize Minimum background size. Set any axis to -1 to have no minimum size
Vec2 maxSize Maximum background size. Set any axis to -1 to have no maximum size
Color textColor text color
Color backColor background color
Vec2i pos Position of upper left corner
int cursor_pos Index of character, where is currently text cursor.
float textCursorTickRate text cursor blink length

Clone this wiki locally