LWXGL’s interactive elements — buttons and checkboxes — respond to mouse hover and click events evaluated each frame duringDocumentation 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.
GRenderWindow. Both element types use a nibble-packed color byte to express two color roles (fill and border) in a single integer argument, keeping the API compact while still supporting distinct visual states.
Nibble-Packed Color Bytes
Several functions accept a singleint whose low 4 bits (nibble) encode the fill color index and whose high 4 bits encode the border color index. This is referred to throughout the docs as a nibble-packed color byte.
| Bits | Role | Extractor macro |
|---|---|---|
[3:0] — low nibble | Fill (background) color index | L(b) |
[7:4] — high nibble | Border (outline) color index | H(b) |
0x78 has low nibble 8 (dark gray fill) and high nibble 7 (light gray border).
GCreateButton
id. The button renders differently depending on mouse state: the u colors are used when the cursor is outside the button, hvr when the cursor is hovering, and p while the left mouse button is held down. The onclick callback fires on left-click release while the cursor is inside the button bounds.
Element slot index. If an element already exists at this ID it is freed and replaced.
X coordinate of the button’s top-left corner.
Y coordinate of the button’s top-left corner.
Width of the button in pixels.
Height of the button in pixels.
Nibble-packed color byte for the unpressed / idle state. Low nibble = fill index, high nibble = border index.
Nibble-packed color byte for the hover state (cursor inside, not clicking). Low nibble = fill index, high nibble = border index.
Nibble-packed color byte for the pressed state (cursor inside, left button held). Low nibble = fill index, high nibble = border index.
Null-terminated string drawn centered inside the button. The pointer is stored directly — do not free or mutate the string after passing it.
Function called when the user releases the left mouse button while the cursor is inside the button. Pass
NULL for no callback.Buttons are automatically suppressed while a modal dialog is open (
GQueryModalOpen() returns non-zero). Hover and click states will not trigger, and onclick will not fire until the modal is dismissed.GCreateCheckbox
id. A checkbox renders as a square box that toggles its checked state on each left-click. When checked, a filled inner square is drawn inside the box (4-pixel inset on each side). An optional text label is displayed to the right of the box.
Element slot index. If an element already exists at this ID it is freed and replaced.
X coordinate of the checkbox square’s top-left corner.
Y coordinate of the checkbox square’s top-left corner.
Width and height of the checkbox square in pixels. The same value is used for both dimensions.
Nibble-packed color byte for the checkbox square. Low nibble = fill index, high nibble = border index. The checked indicator (inner square) is drawn using the border color (high nibble).
Single palette index (0–15) for the label text color. Unused if
label is NULL.Null-terminated string displayed to the right of the checkbox box. Pass
NULL to render the box with no accompanying label.The checkbox starts unchecked (
checked = 0) when first created. Calling GCreateCheckbox again on the same ID resets it to unchecked.GGetCheckbox
id.
Element slot index of the checkbox to query.
1 if the checkbox is currently checked, 0 if unchecked.
Example
The example below creates a submit button whoseonclick handler reads a checkbox’s state, plus a standalone checkbox for an “agree to terms” toggle. Per-frame logic is handled in the on_every callback passed to GSimpleWindowLoop.