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

inputTextHandler(data: ImGuiInputTextCallbackDataPtr): Int

The currently installed InputText handler.

Name Type
data ImGuiInputTextCallbackDataPtr
Returns
Int

inputText(handler: Function): ImGuiCallbackPtr

Install handler and return the trampoline pointer to pass as callback.

Name Type
handler Function
Returns
ImGuiCallbackPtr

dispatchInputText(dataAddr: Float): Int

Called by the DCImGuiCallbacks.cs bridge.

Name Type
dataAddr Float
Returns
Int

sizeConstraintsHandler(data: ImGuiSizeCallbackDataPtr): Void

The currently installed size-constraints handler.

Name Type
data ImGuiSizeCallbackDataPtr

sizeConstraints(handler: Function): ImGuiCallbackPtr

Install handler and return the trampoline pointer to pass as customCallback.

Name Type
handler Function
Returns
ImGuiCallbackPtr

dispatchSizeCallback(dataAddr: Float): Void

Called by the DCImGuiCallbacks.cs bridge.

Name Type
dataAddr Float

comboGetterHandler(idx: Int): String

The currently installed combo items getter.

Name Type
idx Int
Returns
String

comboGetter(handler: Function): ImGuiCallbackPtr

Install handler and return the trampoline pointer to pass as getter.

Name Type
handler Function
Returns
ImGuiCallbackPtr

dispatchComboGetter(userData: Float, idx: Int): Float

Called by the DCImGuiCallbacks.cs bridge.

Name Type
userData Float
idx Int
Returns
Float

selectionAdapterHandler(storage: ImGuiSelectionBasicStoragePtr, idx: Int): Int

The currently installed index-to-storage-id adapter.

Name Type
storage ImGuiSelectionBasicStoragePtr
idx Int
Returns
Int

selectionAdapter(handler: Function): ImGuiCallbackPtr

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
Returns
ImGuiCallbackPtr

dispatchSelectionAdapter(storageAddr: Float, idx: Int): Int

Called by the DCImGuiCallbacks.cs bridge.

Name Type
storageAddr Float
idx Int
Returns
Int

Private Members

comboScratch: Float

COMBO_SCRATCH_CAP: Int

comboScratchWrite(s: String): Float

Copy s (clamped UTF-8) into the persistent scratch and return its address.

Name Type
s String
Returns
Float

Metadata

Name Parameters
:hxGen -