Shawn_wicky
Shawn_wicky

Reputation: 61

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?

Upvotes: 3

Views: 2090

Answers (1)

Omar
Omar

Reputation: 752

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;

Upvotes: 5

Related Questions