Imgui: InputText gets messed up if given empty label

Created on 15 Oct 2017  ·  3Comments  ·  Source: ocornut/imgui

To be more precise, I have an InputText which up until recently worked perfectly.
I wanted to move the labels to the left side and found another issue here where the solution given was to use:

ImGui::Text(label); ImGui::SameLine();
ImGui::InputText(#hidden label....)

I assumed hidden meant empty string, since null does not work.
But then the InputText did not behave properly when keys were pressed. Did not update the visibe string,nor did it return a changed==true.

Followed the debugger and edit_state.TempTextBuffer and buf_display get changed to the new string as well as the local value_changed flag, but somewhere along the road , the value of the boolean changes to false.

Most helpful comment

Please read the FAQ How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on labels/IDs. in imgui.cpp.
You need unique ID, which you can obtain by using e.g. ##label.

All 3 comments

Forgot to mention that at this point, I have the same wrapper code around two Input fields, one is an InputInt and the other an InputText. InputInt with an empty label("") works ok. InputText doesn't.
When I change the label from "" to " ", it works.

Please read the FAQ How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on labels/IDs. in imgui.cpp.
You need unique ID, which you can obtain by using e.g. ##label.

Right. I used Push/Pop ID elsewhere but didn't think to look to how the ID thing works. I had the same conflict over buttons in the same scope with the same label. I also used it wrong. Thought it was about setting the id for the next control, not that it creates a scope whose name takes part in the hash of the scoped controls.

Anyway thanks for the help and sorry for the unnecessary issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

noche-x picture noche-x  ·  3Comments

bogdaNNNN1 picture bogdaNNNN1  ·  3Comments

CesaragsUC picture CesaragsUC  ·  3Comments

namuda picture namuda  ·  3Comments

Folling picture Folling  ·  3Comments