LWXGL uses a callback registration model for input events. Each event type has a single slot; calling the sameDocumentation 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* function again replaces the previous handler. Callbacks are invoked from within the main window loop — you do not need to poll a queue manually.
All callbacks registered here are blocked while a modal dialog is open, with the exception of EventAttachDelete (which is still processed if Ctrl+Escape is pressed).
EventAttachKey
XkbSetDetectableAutoRepeat(display, True, NULL) during window creation, which enables detectable auto-repeat — the X server sends real KeyPress events for every repeated key while it is held. The callback is therefore invoked on every auto-repeat event, not just on the initial press. Use QueryKeyDown in the per-frame callback if you only want to act on the held state without receiving repeated callbacks.
The key argument passed to the callback is an ASCII value for printable characters, or one of the following constants for special keys:
| 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 + 1 | 151 | F1 |
KEY_FN + 2 | 152 | F2 |
| … | … | … |
KEY_FN + 12 | 162 | F12 |
\n (10) | 10 | Enter / Return |
- Ctrl+Escape — triggers
DeleteWindow()(window close) - F12 — toggles the debug overlay
Callback function. Receives the key value as described above.
Key callbacks fire before the per-frame callback. If a modal is open,
Key is not called — modal input is handled internally.EventAttachClick
btn | Button |
|---|---|
1 | Left |
2 | Middle |
3 | Right |
4 | Scroll wheel up |
5 | Scroll wheel down |
- A modal dialog is currently open
- The release occurred over a button element (the button’s own
onclickhandler fires instead) - The release occurred over a checkbox element (the checkbox toggle fires instead)
- Scroll wheel events (
4/5) over a console element or when window scroll is enabled
Callback function.
x and y are window-relative cursor coordinates; btn is the button identifier.EventAttachDelete
WM_DELETE_WINDOW message or when Ctrl+Escape is pressed. The callback must return an integer:
| Return | Effect |
|---|---|
1 | Close is confirmed — window exits on the next loop iteration |
0 | Close is cancelled — window remains open |
Callback function. Return
1 to allow the window to close, 0 to prevent it.EventAttachResize
FLAG_RESIZE was passed to CreateWindow. The callback receives the new window dimensions in pixels.
Resize events are coalesced — if multiple ConfigureNotify events are queued, only the final dimensions are delivered.
Callback function.
w and h are the new window width and height in pixels.Scroll Event
The scroll event is not registered through a standaloneEventAttach* function. Instead, it is provided as the third argument to ReserveScroll, which must be called before CreateWindow:
Scroll callback is invoked whenever the scroll offset changes — either from the user scrolling with the mouse wheel or from a window resize that adjusts the scroll clamp.
| Argument | Meaning |
|---|---|
height | Total virtual canvas height in pixels |
scrollbar_color | 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. |
Scroll | void (*)(int offset) — called with the new scroll offset in pixels |
QueryScroll() for polling the current offset without a callback.