LWXGL provides a built-in modal system that renders a centered dialog over the window contents without requiring any additional elements. While a modal is open, all user callbacks (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.
EventAttachKey, EventAttachClick) are suppressed and button/checkbox elements are not interactive — only the modal’s own OK and Cancel buttons are hit-tested.
There is one global modal slot. Calling SpawnModal while another modal is visible replaces it immediately.
Modal Types
| Constant | Value | Dialog layout |
|---|---|---|
MODAL_ALERT | 0 | Message text + OK button |
MODAL_CONFIRM | 1 | Message text + OK button + Cancel button |
MODAL_INPUT | 2 | Message text + text input field + OK button + Cancel button |
SpawnModal
strdup, so passing a stack-allocated string is safe.
Clicking OK sets the modal to inactive and calls on_confirm (if non-NULL). Clicking Cancel (on MODAL_CONFIRM or MODAL_INPUT) sets the modal to inactive without calling the callback. There is no cancel callback — use QueryModalOpen() to detect whether the modal was dismissed.
The input buffer is zeroed each time SpawnModal is called, so previous input does not persist across modal invocations.
Dialog type —
MODAL_ALERT (0), MODAL_CONFIRM (1), or MODAL_INPUT (2).Message text to display in the dialog. Copied with
strdup — the caller’s string does not need to remain valid after this call. Maximum display width depends on the window width.Callback invoked when the user clicks OK. May be
NULL for alert dialogs where you only need to notify the user. For MODAL_INPUT dialogs, call GetModalInput() inside this callback to retrieve the user’s text.QueryModalOpen
1 if a modal dialog is currently visible, 0 otherwise. Use this to gate game logic or polling that should be paused while the user is interacting with a dialog.
GetModalInput
MODAL_INPUT dialog, null-terminated. Input is capped at 150 characters.
This pointer is only meaningful after the user has clicked OK in a MODAL_INPUT dialog — call it from the on_confirm callback. The buffer is owned by LWXGL; do not free() it. The contents are overwritten the next time SpawnModal is called.
Scroll Utilities
These two functions relate to the optional window-scroll feature and are documented here alongsideReserveScroll (covered fully in the Events API).
QueryScroll
0 and max(0, virtual_height - window_height). Returns 0 if scrolling is not enabled.
ReserveScroll
CreateWindow. See the Events API for full documentation.
Total virtual canvas height in pixels (must be greater than the window height to be scrollable).
Two palette indices packed into one byte: low nibble (
L) = track background fill color; high nibble (H) = thumb fill color. Pass CLR_NONE (-1) to hide the scrollbar entirely.Callback invoked with the new offset whenever scrolling occurs. May be
NULL.