Comments (12)
Classic id conflict, see here for details:
https://github.com/ocornut/imgui/blob/master/docs/FAQ.md#q-about-the-id-stack-system
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 ImGui::PushID( (int)row );
and ImGui::PopID();
at the start and end of your loop body.
from imgui.
FYI if you use PushID(row)
you don't need to decorate label names, a simple ##DistanceDrag
works.
Please browse the Tables section of the Demo as it exhibit many use cases.
from imgui.
Closing as answered, thank you Daniel!
Indeed the provided link should give you all answers.
I will amend the FAQ entry with a GIF to highlight the common issue.
from imgui.
I added code (c383795e) to generate this gif:
And added it to the FAQ entry, along with corresponding UI code.
from imgui.
Thanks for your time, I've been so lost lately with this problem
from imgui.
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.
I've read somewhere in a closed issue that naming a label with a pre "##" would hide the label during rendering, even tho it is true on a different row of my table ends up pasting the label without the first character. While it starts messing with the other input fields. Not sure if it is a pointer problem or something related to me using a vector<pair<float, float>> levels
to this particular case. I'll be posting also a gif representing this problem.
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();
}
}
from imgui.
Your problem is here:
"##DistanceDrag" + (row)
That is not how you construct strings in C++. That's pointer arithmetic. You basically take the string, which is a char*
, then offset the pointer itself by the current value of row. So your labels for rows 0, 1 and 2 are "##DistanceDrag"
, "#DistanceDrag"
and "DistanceDrag"
respectively, which fits with the observed behavior.
If you want to build your labels with values pasted in, that's called string formatting. One of many ways: take a look at sprintf_s
and use it to format a string into a local char array of sufficient size.
from imgui.
@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 std::format
since I'm working with C++20.
TLDR: Labels are now actually invisible but the fields interfering with each other persists.
from imgui.
TLDR: Labels are now actually invisible but the fields interfering with each other persists.
I'm pretty sure this is your culprit: sortVPair(tS.levels);
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, ImGui::IsItemDeactivatedAfterEdit()
can help with that.
from imgui.
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?
from imgui.
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 ImGui::SetNextItemWidth(-FLT_MIN)
. Slightly negative as an offset to the available size. If that doesn't work, you need to calculate or know the size yourself and can use that as a positive value.
from imgui.
Thanks to you both. Its all up and running. Thanks for your help!
from imgui.
Related Issues (20)
- ImDrawList rects aren't perfect HOT 7
- Running ImGui app on Arm Processor (Allwinner H3 with mali 400 -> orangepi one) HOT 1
- Can no longer use ctrl shortcuts in InputText's as of v1.90.6 HOT 4
- ImGui::BeginTooltip() should allow specifying override HOT 4
- No Hover Flags in ImGui::IsAnyItemHovered() HOT 4
- Keeping combo open after clicking selectable
- Stretch table to window scrollable size
- TitleBarRect does not contain FramePadding. This will cause the window to not move correctly after ConfigWindowsMoveFromTitleBarOnly is enabled.
- Small window flickering when move out the edge of main window. HOT 5
- Unresolved external symbol, all ImGui CPP Files are included HOT 3
- Jumping the user to a different part of the GUI HOT 3
- Mouse resize child window HOT 1
- Changing hIcon and hIconSm are not changing to custom icon HOT 1
- io.WantCaptureMouse doesn't work for scrollwheel HOT 3
- How to use ImGui rounding style for ImGui::MenuItems? HOT 2
- Scale to window maintaining aspect ratio, but Viewport won't center HOT 2
- Please help me to clarify the concepts of some specific terms HOT 2
- WebGPU ImGui::Image not accepts different texture formats HOT 3
- InputText CTRL+V paste fails if text is too long HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imgui.