5

Is it possible to have two Buttons with the same Button Text using the "dear imgui"?
Because generating two or more ImGui::Button("PRESS") will lead to the situation that only the first is reacting on selection (tested on GCC / Win64 / MinGW)

1 Answer 1

12

Yes.

The reason only the first of two ImGui::Button("Press") objects will register is because - by default - ImGui uses the button's text as its identifier.

You can circumvent this by either using PushID() and PopID() around your buttons to create a new ID stack, or by adding additional information to your button by adding "##" after the button text.

E.g.: ImGui::Button("Press##1") and ImGui::Button("Press##2") will both register while both only having "Press" on the button.

All text after "##" will only be used to set that button's identifier and won't be displayed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.