Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Buttons with the same Button Text using "dear imgui"

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)

like image 987
alfetta Avatar asked Feb 04 '23 18:02

alfetta


1 Answers

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.

like image 70
zedutchgandalf Avatar answered Feb 17 '23 01:02

zedutchgandalf