-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
Hey!
I have noticed some weird behaviour of zgui.textInput that I do not understand.
Let's say we have the following code written in C/C++:
static char text[1024] = "";
static ImGuiInputTextFlags flags = ImGuiInputTextFlags_EnterReturnsTrue;
if(ImGui::InputText("##source", text, IM_ARRAYSIZE(text), flags)) {
fprintf(stdout, "%s\n", text);
}
and now we want to convert it into Zig using zig-gamedev/zgui lib.
const static = struct {
var buf: [128]u8 = undefined;
};
if (zgui.inputText(
"##source",
.{
.buf = &static.buf,
.flags = .{
.enter_returns_true = true,
},
},
)) {
std.debug.print("{s}\n", .{&static.buf});
}
Now if you do this:
- Enter "hello"
- Press Enter
- See "hello" in terminal
- Focus input again
- ctrl+a / cmd+a (select text)
- Type 'x'
- Press Enter
For the C variant, you will see x
in the terminal as expected
For the Zig variant, you will see xllo
in the terminal.
It could be definitely that I don't understand some very basic stuff about system programming/C/Zig as I'm just entering this realm. Could you please help me understand what is going on here?
Metadata
Metadata
Assignees
Labels
No labels