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

InputText gets messed up if given empty label #1369

Closed
NPatch opened this issue Oct 15, 2017 · 3 comments
Closed

InputText gets messed up if given empty label #1369

NPatch opened this issue Oct 15, 2017 · 3 comments

Comments

@NPatch
Copy link

NPatch commented Oct 15, 2017

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.

@NPatch
Copy link
Author

NPatch commented Oct 15, 2017

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.

@ocornut
Copy link
Owner

ocornut commented Oct 15, 2017

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.

@ocornut ocornut closed this as completed Oct 15, 2017
@NPatch
Copy link
Author

NPatch commented Oct 16, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants