-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Can't select only 1 input when inputs are slightly close to each other #7581
Comments
Classic id conflict, see here for details: It has nothing to do with proximity on the screen. You basically have submitted multiple items with the same id, reacting as one. One way you can solve it is by using |
Closing as answered, thank you Daniel! |
I added code (c383795e) to generate this gif: |
Thanks for your time, I've been so lost lately with this problem |
I'm sorry I have to reopen the issue, I'm not sure if I understood this. I tried using the PushID and PopID calls to manage this it. Here's my updated code: {
if (ImGui::Begin("Tesselation Shader Properties")) {
if (tS.levels.size() == 0)
tS.levels.push_back({ 0.f, 0.f });
sortVPair(tS.levels);
static ImGuiTableFlags flags = ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable;
if (ImGui::BeginTable("table_scrolly", 2, flags, ImVec2(-FLT_MIN, 5 * ImGui::GetTextLineHeightWithSpacing()))) {
for (size_t row = 0; row < tS.levels.size(); row++) {
ImGui::TableNextRow();
{
ImGui::TableNextColumn();
ImGui::PushID(row);
ImGui::DragFloat("##DistanceDrag" + (row), &( tS.levels[row].first ), 1.f, 0.f, 0.f, "Distance > %.1f");
ImGui::PopID();
}
{
ImGui::TableNextColumn();
ImGui::PushID(row);
ImGui::DragFloat("##LevelDrag" + (row), &( tS.levels[row].second ), 1.f, 0.f, 0.f, "Level : %.1f");
ImGui::PopID();
}
}
ImGui::EndTable();
}
if (ImGui::Button("+"))
tS.levels.push_back({ 0.f, 0.f });
ImGui::SameLine();
ImGui::BeginDisabled(tS.levels.size() <= 1);
if (ImGui::Button("-"))
tS.levels.pop_back();
ImGui::EndDisabled();
ImGui::End();
}
} |
Your problem is here: That is not how you construct strings in C++. That's pointer arithmetic. You basically take the string, which is a If you want to build your labels with values pasted in, that's called string formatting. One of many ways: take a look at |
@GamingMinds-DanielC That does solve the label issue, for sure. I was wondering if it actually had something to do to pointer arithmetic. Although the behaviour itself of the change of values affecting the other fields keeps going and since the smoking gun of pointer arithmetic was already found, i then don't know what might be the problem in the first place. Nice catch tho, thanks. Btw, I ended up using TLDR: Labels are now actually invisible but the fields interfering with each other persists. |
I'm pretty sure this is your culprit: You should avoid changing underlying values (if you swap them due to sorting, that counts) while you are actively editing them. My advice would be to sort only after an edit, |
Thanks, that seems to solve the case! You were right. Since I have your attention do you know how in my case I could make the element widgets stretch themselves to the full width of the cell? |
Never tried if that works in table cells, but you can try |
FYI if you use Please browse the Tables section of the Demo as it exhibit many use cases. |
Thanks to you both. Its all up and running. Thanks for your help! |
Also #74, #96, #480, #501, #647, #654, #719, #843, #894, #1057, #1173, #1390, #1414, #1556, #1768, #2041, #2116, #2330, #2475, #2562, #2667, #2807, #2885, #3102, #3375, #3526, #3964, #4008, #4070, #4158, #4172, #4199, #4375, #4395, #4471, #4548, #4612, #4631, #4657, #4796, #5210, #5303, #5360, #5393, #5533, #5692, #5707, #5729, #5773, #5787, #5884, #6046, #6093, #6186, #6223, #6364, #6387, #6567, #6692, #6724, #6939, #6984, #7246, #7270, #7375, #7421, #7434, #7472, #7581, #7724, #7926, #7937 and probably more.. Tagging to increase visibility!
Version/Branch of Dear ImGui:
Version 1.89.3 , Branch: master
Back-ends:
imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp
Compiler, OS:
Windows 11 + MSVC 2022
Full config/build information:
No response
Details:
My Issue/Question:
So, I've been using ImGui for over 1 year in this project and I've found this problem more than one time.
When I display multiple inputs slightly close to each other it ends up on trying to select only one of them pick everything from that column p.e... I've seen this appear with ungrouped input too. Here's a few lines of code where this problem exhists:
Even tho I'm using spacing and grouping the input by row it does not allow me to only select one input.
Here's a video to showcase the problem:
Screenshots/Video:
Screen.Recording.-.Made.with.RecordCast.2.webm
Minimal, Complete and Verifiable Example code:
The text was updated successfully, but these errors were encountered: