Closed Jarrio closed 6 years ago
Hello, You'd need to use cpp.Callable.fromStaticFunction passing a static haxe function which satisfies ImGuiTextEditCallback to generate a cpp callback function. You can look at the examples to see similar use with the clipboard callbacks.
If you get it working a PR would be very useful as I haven't got around to making bindings for the text callback.
Here's what I've got so far:
var callback = Callable.fromStaticFunction(updateTradingPair);
ImGui.inputText("", input_text_1, ImGuiInputTextFlags.CallbackAlways, callback);
Where callback
is typedef ImGuiTextEditCallback = Callable<RawPointer<ImGuiTextEditCallbackData>->Void>;
During compilation, I am getting the following error
error C2664: 'bool ImGui::linc::InputText(const char *,Array<char>
&,ImGuiInputTextFlags,ImGuiTextEditCallback)': cannot convert argument 4 from 'cpp::Function<void (ImGuiTextEditCallbackData *)>' to 'ImGuiTextEditCallback''
I've got the following definitions in the linc files
//.h
extern bool InputText(const char* _label, Array<char> &_buffer, ImGuiInputTextFlags _flags = 0, ImGuiTextEditCallback callback = NULL);
//.cpp
bool InputText(const char* _label, Array<char> &_buffer, ImGuiInputTextFlags _flags, ImGuiTextEditCallback callback)
{
return ImGui::InputText(_label, &_buffer[0], _buffer->length, _flags, callback);
}
I've just merged a branch with the master which updates linc_imgui to imgui 1.60 and also adds the bindings for text callbacks which you're after. There a quick example in the luxe sample if you're still unsure.
Thanks, works nicely now!
I've added what I think to be correct a copy of the way you have setup
ImGuiSizeConstraintCallbackData
for InputText, keeping to the original source code herehttps://github.com/ocornut/imgui/blob/master/imgui.h#L361.The problem is I can't seem to figure out how to turn a haxe function into a
typedef ImGuiTextEditCallback = Callable<Pointer<ImGuiTextEditCallbackData>->Void>;
Could you help? If I can test this, I'll also push the changes as a PR 👍