These utility functions operate on the shared element list — the central array that holds every text, button, image, input, checkbox, console, and rectangle element. Each element is identified by its integer slot indexDocumentation 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.
id. Functions that accept id are valid for elements of any type unless otherwise noted.
DeleteElement
index and sets the slot to NULL. The slot can be reused for a new element immediately after deletion.
Type-specific cleanup performed:
- Text (
type 0): frees the string if it was copied (created withCreateCopiedText) - Image (
type 4): destroys theXImage, freesdata,prev, and font buffer, frees the off-screenPixmap - All other types: deletes the type-specific struct
DeleteElement on a NULL slot or an out-of-bounds index is safe (no-op).
Element slot index to delete.
ElemModifyBounds
id. The element is moved to (x, y). If w is -1, the existing width is preserved; similarly for h.
This affects rendering position and hit-testing immediately — no explicit refresh is needed.
Element slot index.
New X position (window coordinates).
New Y position (window coordinates).
New width in pixels, or
-1 to leave the current width unchanged.New height in pixels, or
-1 to leave the current height unchanged.ElemSetVisible
id is rendered and participates in hit-testing.
visible | Effect |
|---|---|
1 | Visible and interactive (default) |
0 | Hidden and not hit-tested |
Element slot index.
1 to show the element, 0 to hide it.ElemInside
1 if the mouse cursor is currently inside the bounds of element id, 0 otherwise. Returns 0 unconditionally when a modal dialog is open.
For checkbox elements, the hit area is extended to include the label text in addition to the checkbox square.
Element slot index.
ElemAnchor
ids array.
When anchor != 0, each element’s current Y position is saved as its anchor offset (e->anchor = e->y). When scroll is active, ResolveAnchors will set the element’s Y to scroll_offset + anchor_offset, keeping it at a fixed visual position relative to the viewport.
When anchor == 0, the anchor is cleared: each element’s Y position is first restored to the previously saved anchor value (e->y = e->anchor), and then the anchor field is set to INT_MIN to mark it as un-anchored. The element reverts to a static position and will no longer be repositioned by ResolveAnchors.
Non-zero to set anchors (using current Y positions),
0 to clear anchors.Array of element slot indices to anchor or un-anchor.
Number of elements in the
ids array.ResolveAnchors
scroll_offset + anchor_offset. Must be called once per frame in the on_every callback when scroll is enabled and you have anchored elements (e.g. a fixed header toolbar).
Elements without an anchor (anchor == INT_MIN) are skipped.
SetGlobalBold
9x15 (normal) and 9x15bold (bold). Affects all text elements, button labels, console output, and any other text rendered through the GC. Returns 1 on success, 0 if the font could not be loaded.
1 to switch to bold, 0 to switch to normal weight.