LWXGL processes X11 events internally on every frame and dispatches them to a set of user-provided callback functions registered through theDocumentation 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.
EventAttach* and EnableResizing APIs. Each registration function accepts a function pointer and stores it globally — only one callback per event type is active at a time, and passing NULL disables that callback. Callbacks are invoked after LWXGL’s own element event handling is complete, so element-level interactions (button clicks, input field key strokes, etc.) consume events before the user callbacks see them.
EventAttachKey
Registers a callback invoked on each key-press event that reaches the application layer.
10 (ASCII line-feed). Arrow keys and F-keys are mapped to the special constants listed in the table below. The callback is not called when a modal dialog is open, or when an Input or Console element is focused (hovered), as those elements consume key events themselves.
Function pointer to invoke on each key press. Receives a single
int containing the ASCII code or a KEY_* constant. Pass NULL to unregister.Special key constants
| Constant | Value | Key |
|---|---|---|
KEY_LEFT | 170 | Left arrow |
KEY_RIGHT | 171 | Right arrow |
KEY_UP | 172 | Up arrow |
KEY_DOWN | 173 | Down arrow |
KEY_FN | 150 | F-key base — add 1–12 for F1–F12 (KEY_FN + 1 = F1, KEY_FN + 12 = F12) |
The key callback fires on the initial press event. LWXGL enables detectable auto-repeat via
XkbSetDetectableAutoRepeat, so holding a key will generate repeated press events without spurious synthetic release events between them. For continuous per-frame polling use QueryKeyDown instead.EventAttachClick
Registers a callback invoked on mouse button release events not consumed by a UI element or modal.
Button, Checkbox, Console, or other interactive element. Scroll-wheel events (buttons 4 and 5) are also delivered here when no scrollable element is hovered and scroll mode is not active.
Function pointer to invoke on button release.
x and y are the cursor position relative to the window. btn is the button index (see table). Pass NULL to unregister.Button values
btn | Description |
|---|---|
1 | Left mouse button |
2 | Middle mouse button (wheel click) |
3 | Right mouse button |
4 | Scroll wheel up |
5 | Scroll wheel down |
EventAttachDelete
Registers a callback invoked when the window manager’s close button (WM_DELETE_WINDOW) is activated.
1 to allow the window to close (equivalent to calling DeleteWindow()). Return 0 to veto the close request — useful for showing a “Save before exit?” confirmation modal.
Function pointer returning an
int. Return 1 to confirm close, 0 to cancel. Pass NULL to restore the default behavior (immediate close on any WM delete event).EnableResizing
Removes fixed-size window manager hints and registers a callback invoked when the window is resized.
PMinSize | PMaxSize hints that lock the window to its initial dimensions. Calling EnableResizing clears those hints (or adjusts them to allow resizing within scroll-mode constraints) and stores the callback. The callback is called from the ConfigureNotify handler after LWXGL has updated its internal win_w/win_h and reconstructed the back-buffer to match the new dimensions.
Function pointer called with the new window width and height in pixels whenever a
ConfigureNotify event changes the window size.When scroll mode is active (
ReserveScroll was called), resizing is horizontally unlimited but the maximum height is clamped to the virtual canvas height so that the scrollable area is never obscured.