LWXGL text input elements allow users to type freeform text directly in the window. An input field becomes active whenever the mouse cursor is positioned over it — there is no explicit focus click required. Typed printable characters are appended to the field’s internal buffer, and an underscore cursor is drawn at the end to indicate the active state. The nibble-packed color byte convention (shared with buttons) controls the inactive and hover visual states independently.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/dressedalarm184/lwxgl/llms.txt
Use this file to discover all available pages before exploring further.
GCreateInput
id. The internal character buffer is always 128 bytes and is zero-initialized on creation. Characters in the printable ASCII range (codes 32–126) are accepted; Backspace (code 8) removes the last character. Input is captured when the mouse cursor is inside the element bounds and no modal dialog is open.
Element slot index. If an element already exists at this ID it is freed and replaced.
X coordinate of the input field’s top-left corner.
Y coordinate of the input field’s top-left corner.
Width of the input field in pixels. Pass
-1 to auto-size: the width is calculated as (max + 1) * 9 + 10, which fits exactly max characters in the 9x15 font with padding and room for the cursor indicator.Height of the input field in pixels. A height of
22–28 pixels is typical for a single-line field using the 9x15 font.Nibble-packed color byte for the inactive state (cursor not over the field). Low nibble = fill index, high nibble = border index. See the Button & Checkbox page for a full explanation of nibble packing.
Nibble-packed color byte for the hover / active state (cursor over the field). Low nibble = fill index, high nibble = border index.
Maximum number of characters the field will accept. The internal buffer is always 128 bytes total, so
max must be ≤ 127 to leave room for the null terminator.Input is hover-driven: whichever input element the cursor is over at render time receives keyboard events. If two input elements overlap, the one with the lowest slot index that overlaps the cursor takes input (elements are scanned in index order).
GGetInput
id. You can read or inspect this string at any time — for example, in a button’s onclick handler or in the per-frame GSimpleWindowLoop callback.
Element slot index of the input field to query.
char* pointing directly into the element’s internal 128-byte buffer. The string is always null-terminated. The pointer remains valid until the element is deleted with GDeleteElement. This is not a copy — modifications through this pointer write directly into the element’s storage.
Example
The example below creates a name input field and a submit button. The button’sonclick handler reads the current input value and prints it. The input auto-sizes its width to fit 31 characters using w=-1.