'Change ImGui Button name when click it

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?



Solution 1:[1]

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;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Omar