Buttons, input fields, and checkboxes are LWXGL’s interactive widget elements. They respond to mouse hover and click automatically — no event-attachment code is required for their built-in visual states and value changes.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.
Packed color bytes
Buttons, inputs, and checkboxes accept packed color bytes for their color parameters. A packed byte encodes two palette indices in oneint:
- High nibble (
H, bits 7–4) — border / outline color (palette index 0–15) - Low nibble (
L, bits 3–0) — fill / background color (palette index 0–15)
0x7F means border = palette 7 (gray), fill = palette 15 (white).
GCreateButton
Element slot index.
Left edge in window pixels.
Top edge in window pixels.
Width in pixels.
Height in pixels.
Packed color byte for the unpressed (normal) state. High nibble = border, low nibble = fill.
Packed color byte for the hover state (cursor inside, mouse button up).
Packed color byte for the pressed state (cursor inside, left mouse button held).
Button text, centered within the button bounds. Each character is 9 px wide.
Callback invoked when the left mouse button is released over the button. May be
NULL for a button with no action.When a button’s
onclick fires, the global GEventAttachClick callback is suppressed for that event — the click is consumed by the button.GCreateInput
_) is appended to the visible text while the field is active.
Element slot index.
Left edge in window pixels.
Top edge in window pixels.
Width in pixels. Pass
-1 to auto-size to (max + 1) * 9 + 10 pixels, which fits the maximum character count plus the cursor character.Height in pixels.
24 is a typical value for single-line inputs.Packed color byte for the inactive (cursor outside) state.
Packed color byte for the active/hover (cursor inside) state.
Maximum number of characters the field accepts. The internal buffer is fixed at 128 bytes;
max should be ≤ 127 to leave room for the null terminator.GGetInput
id.
Element slot index of an existing input element.
char* — pointer to the internal 128-byte buffer. This is the live buffer — its contents change as the user types. Treat it as read-only: do not write to, free, or retain it past the element’s lifetime.
GCreateCheckbox
size - 8 px filled square).
Element slot index.
Left edge of the checkbox square in window pixels.
Top edge of the checkbox square in window pixels.
Side length in pixels of the checkbox square. Also determines the element’s bounding box height. Typical value:
16.Packed color byte for the checkbox square. High nibble = border color, low nibble = fill color.
Palette index (0–15) for the label text color.
Text displayed to the right of the box, offset by 3 px. Pass
NULL for no label. The label pointer is stored by reference — do not free or move it while the element exists.GGetCheckbox
id.
Element slot index of an existing checkbox element.
int — 1 if checked, 0 if unchecked.