Change ImGui Button name when click it

1.6k Views Asked by At

Is it possible to change the button name when you click it?

I'm currently doing a imgui project. I want to change the Global view and the Local view in one button using ImGui::Button. Is that possible in the current ImGui version right now?

1

There are 1 best solutions below

0
On

Just change the label of the button depending on your current state.. And you can use the ### operator (described in FAQ) to keep a stable ID.

if (ImGui::Button(view_is_local ? "Local###ViewMode" : "Global###ViewMode"))
    view_is_local = !view_is_local;