ImGuiCallbacks
imgui.ImGuiCallbacks (Class)
Cross-target C callback trampolines (hand-written, never regenerated).
DESIGN CONTRACT: there is ONE static handler slot per callback kind, and
one shared C trampoline dispatching to it. This is deliberate (no Map, no
garbage, no hidden state): correctness comes from installing the handler
SYNCHRONOUSLY, right before the call that fires it. Concretely:
inputText / comboGetter: the callback fires DURING the widget call
itself. Install just before each widget call (cheap, one static
assignment); any number of widgets with different handlers is safe.
sizeConstraints: the callback fires during the NEXT begin(). Keep
setNextWindowSizeConstraints(...) and its begin() back to back,
without installing another size handler in between.
selectionAdapter: the trampoline pointer is STORED in the
ImGuiSelectionBasicStorage struct and fires during
beginMultiSelect / applyRequests / endMultiSelect. Reinstall YOUR
handler right before each such block (every frame): with several
storages using different index-to-id mappings, the last installed
handler is the one that runs.
Typical usage:
var cb = ImGuiCallbacks.inputText(myHandler);
ImGui.inputTextEx('Input', buf, 256, flags, cb);
Per target:
- hxcpp: cpp.Callable.fromStaticFunction (a real C function pointer);
- js/wasm: Module.addFunction (requires the wasm built with
-sALLOW_TABLE_GROWTH, done by build/build-web.sh);
- C#/Unity: static delegate + Marshal.GetFunctionPointerForDelegate in the
DCImGuiCallbacks.cs companion (MonoPInvokeCallback for IL2CPP).
Static Members
The currently installed InputText handler.
Install handler and return the trampoline pointer to pass as callback.
| Name |
Type |
handler |
Function |
Called by the DCImGuiCallbacks.cs bridge.
The currently installed size-constraints handler.
Install handler and return the trampoline pointer to pass as customCallback.
| Name |
Type |
handler |
Function |
Called by the DCImGuiCallbacks.cs bridge.
The currently installed combo items getter.
Install handler and return the trampoline pointer to pass as getter.
| Name |
Type |
handler |
Function |
Called by the DCImGuiCallbacks.cs bridge.
The currently installed index-to-storage-id adapter.
Install handler and return the trampoline pointer to store in
storage.adapterIndexToStorageId. Unlike widget callbacks, the adapter
fires during beginMultiSelect/applyRequests/endMultiSelect: REINSTALL
your handler right before each such block (see the class doc contract).
With a single storage or identity mappings, installing once is enough.
| Name |
Type |
handler |
Function |
dispatchSelectionAdapter(storageAddr: Float, idx: Int): Int
Called by the DCImGuiCallbacks.cs bridge.
Private Members
Copy s (clamped UTF-8) into the persistent scratch and return its address.