-
-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Non-working sliders when iterating through vector #654
Copy link
Copy link
Closed
Labels
label/id and id stackimplicit identifiers, pushid(), id stackimplicit identifiers, pushid(), id stack
Description
I've found a pretty weird behavior where I can't influence slider values (I can drag, but the slider always snaps back to the original value).
Basically, the following fails:
std::vector<float> foos;
foos.push_back(0.3);
// ...
for(float s : foos) {
ImGui::SliderFloat("float x", &s, 0.0f, 1.0f);
}
but this works:
std::vector<float> foos;
foos.push_back(0.3);
// ...
for(float &s : foos) {
ImGui::SliderFloat("float x", &s, 0.0f, 1.0f);
}
I'm not sure if this is expected behavior and/or can even be reproduced on other systems (I compiled with g++ 6.1.1), but I'd be interested in the reasons for the failure.
In the attachment, there is a full main.cpp (as a txt, because Github only allows those)
main.cpp.txt
which can be dragged into opengl_example to reproduce the issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
label/id and id stackimplicit identifiers, pushid(), id stackimplicit identifiers, pushid(), id stack