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

CollapsingHeader with same name as InputText confuses collapse action #6

Closed
wdevore opened this issue Apr 24, 2019 · 2 comments
Closed

Comments

@wdevore
Copy link

wdevore commented Apr 24, 2019

Hi, I'm posting this here for now because I can't tell if this is a CImGui issue or ImGui.

I started building an interface when I ran into bug where having a CollapsingHeader and InputText that both have the same label. It took me a while to narrow done the issue. If I have two collapsing headers, for example:

if CImGui.CollapsingHeader("Global")
   returned = CImGui.InputText("Simulation", ...)  <== InputText has same label as Header below
end

if CImGui.CollapsingHeader("Simulation")
end

Then expanding the Global header injects a input text field that happens to have the same label as the Simulation header section. This prevents the Simulation header from expanding. Once I relabeled the input text to something else then things began working again as expected.

Is this expected behavior? I couldn't find anything in the docs that says you can't have two different widget types with the same label. It seems every widget must have a different (i.e. unique) value.

Thoughts?

@Gnimuc
Copy link
Owner

Gnimuc commented Apr 24, 2019

I couldn't find anything in the docs that says you can't have two different widget types with the same label.

I don't think the doc implies this.

Elements that are typically not clickable (such as calls to the Text functions) don't need an ID. Interactive widgets (such as calls to Button buttons) need a unique ID. Unique ID are used internally to track active widgets and occasionally associate state to widgets. Unique ID are implicitly built from the hash of multiple elements that identify the "path" to the UI element.

CollapsingHeader doesn't introduce a new id scope, so we need to add "##"s to enforce id uniqueness.

JamesWrigley added a commit that referenced this issue Jun 9, 2024
@JamesWrigley
Copy link
Collaborator

Closing this because it's an upstream design limitation.

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

3 participants