The Events API lets your application respond to keyboard input, mouse clicks, and window close requests. LWXGL processes all X11 events internally 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.
GHandleWindowEvents. User-registered callbacks are invoked after LWXGL’s own internal handlers have had a chance to consume the event — some inputs (Ctrl+Escape and F12) are always consumed before reaching your callback.
Ctrl+Escape always triggers
GDeleteWindow() and F12 always toggles the debug overlay. These are handled unconditionally inside the key event handler before the user’s key callback is ever invoked.GEventAttachKey
int representing the key that was pressed. For printable ASCII characters the value is the character code (e.g., 'a' = 97). For special keys the value is one of the LWXGL_KEY_* constants defined in libLWXGL.h.
Function to call on key press. Receives the ASCII value for printable characters or an
LWXGL_KEY_* constant for special keys. Pass NULL to unregister the callback.- A modal dialog is open (
GQueryModalOpen()returns1). - The key event was consumed by an input element (the cursor was inside an active input field).
- The key was Ctrl+Escape or F12 (consumed before user callback).
GEventAttachClick
Function to call when a mouse button is released.
x and y are window coordinates; btn is the X11 button number (1 = left, 2 = middle, 3 = right). Pass NULL to unregister.- The click was consumed by a button element (released inside a button’s bounds).
- The click was consumed by a checkbox element (released inside a checkbox’s bounds).
- A modal dialog is open.
GEventAttachDelete
GDeleteWindow() is triggered (e.g., by the WM close button or Ctrl+Escape). The handler’s return value controls whether the close actually proceeds.
Function to call when the window is about to close. Return
1 to allow the close (sets closing = 1). Return 0 to cancel the close (the window remains open). Pass NULL to unregister, which makes every close attempt succeed unconditionally.GQueryMouse
MotionNotify and ButtonPress/ButtonRelease X11 event handlers and reflect the state as of the most recent GHandleWindowEvents call.
Receives the cursor’s X position in window coordinates, or
-1 if the cursor is outside the window.Receives the cursor’s Y position in window coordinates, or
-1 if the cursor is outside the window.Receives the button currently held down (
1=left, 2=middle, 3=right), or 0 if no button is pressed.GQueryKeyboard
LWXGL_KEY_* constant) of one currently depressed key. Up to 8 simultaneous key presses are tracked. Zero bytes indicate empty slots.
(none)
Takes no parameters.
GQueryKeyDown
1 if the key with code ch is currently held down, 0 otherwise. Internally scans the same 8-byte array returned by GQueryKeyboard.
ASCII character code or
LWXGL_KEY_* constant to query.Key Constants
The following constants are defined inlibLWXGL.h for non-printable keys:
| Constant | Value | Key |
|---|---|---|
LWXGL_KEY_LEFT | 170 | Left arrow |
LWXGL_KEY_RIGHT | 171 | Right arrow |
LWXGL_KEY_UP | 172 | Up arrow |
LWXGL_KEY_DOWN | 173 | Down arrow |
LWXGL_KEY_FN | 150 | Function key base (see below) |
LWXGL_KEY_FN + n, where n is the function key number (1–12):
| Key | Value |
|---|---|
| F1 | 151 |
| F2 | 152 |
| … | … |
| F11 | 161 |
| F12 | 162 |
F12 (
LWXGL_KEY_FN + 12 = 162) is consumed by the internal event handler to toggle the debug overlay and never reaches your key callback.