Skip to content

Commit

Permalink
Fix im.input_int()
Browse files Browse the repository at this point in the history
The format for S64 should be "%" PRId64, not "%d". Without this, if you
input a negative number it will be stored as a very large positive
number instead.
  • Loading branch information
binji committed Dec 11, 2024
1 parent a9cec6d commit 2b43f30
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dev/src/imbind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ nfr("input_int", "label,val,min,max", "SIII", "I",
[](StackPtr &, VM &vm, Value &text, Value &val, Value &min, Value &max) {
IsInit(vm);
ImGui::InputScalar(Label(vm, text), ImGuiDataType_S64, (void *)&val,
nullptr, nullptr, "%d", 0);
nullptr, nullptr, "%" PRId64, 0);
if (val.ival() < min.ival()) val = min;
if (val.ival() > max.ival()) val = max;
return val;
Expand All @@ -1197,7 +1197,7 @@ nfr("input_int", "label,val", "SI", "I",
[](StackPtr &, VM &vm, Value &text, Value &val) {
IsInit(vm);
ImGui::InputScalar(Label(vm, text), ImGuiDataType_S64, (void *)&val,
nullptr, nullptr, "%d", 0);
nullptr, nullptr, "%" PRId64, 0);
return val;
});

Expand Down

0 comments on commit 2b43f30

Please sign in to comment.