Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] SliderInt value changing unwantedly on TreeNode click spam #2041

Closed
deniz617 opened this issue Aug 25, 2018 · 1 comment
Closed

[BUG] SliderInt value changing unwantedly on TreeNode click spam #2041

deniz617 opened this issue Aug 25, 2018 · 1 comment
Labels
label/id and id stack implicit identifiers, pushid(), id stack

Comments

@deniz617
Copy link

deniz617 commented Aug 25, 2018

Version/Branch of Dear ImGui:

v1.62

Back-end file/Renderer/OS:

Back-ends: Standart imgui & D3D9
OS: Windows 10 - 64 Bit
Compiler: Standart Visual Studio 2017 C++

My Issue/Question:
So as first im pretty new on imgui(just my first days) this is not a question or i don't need help i just wanted to report this bug that i found while starting to explore imgui.
When you spam to open a 'TreeNode' with a 'SliderInt' under it, the slider changes the value relevant to the mouse position but you don't press the slider. How this happen? On the SliderInt arguments the text(argument0) must be "", if you write " \0" everything works like it should. I Hope i was able to help you improving the library. Keep up the good work & Have a good day!

Standalone, minimal, complete and verifiable example:

//IMGUI NEW FRAME
ImGui_ImplDX9_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();

//BEGIN STUFF

ImGui::Begin("Hello World!");

if (ImGui::TreeNode("Settings"))  //Open the node and change the slider value now spam click the TreeNode you will notice the slider value got changed. 
{
    ImGui::InputInt("Range", &range);
    ImGui::SliderInt("", &range, 1, 15, "Range: %d"); //if arg0 == "" the value changes while spamming the tree node with clicks
    ImGui::TreePop();
}

ImGui::End();

//END STUFF

//IMGUI EndFrame
ImGui::EndFrame();

//IMGUI Render
ImGui::Render();
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());

Screenshots/Video (you can drag files here)

@ocornut
Copy link
Owner

ocornut commented Aug 25, 2018

This is not a bug, you have an ID conflict. Using an empty ID has some rare uses but in 99% cases is not what you want to do. With your setup both the treenode and the slider share the same ID.

If you want an empty label on the Slider you may use “##something”.

Please read the FAQ entry about ID manipulations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
label/id and id stack implicit identifiers, pushid(), id stack
Projects
None yet
Development

No branches or pull requests

2 participants