1

Hello I want to create some buttons with SFML-IMGUI and after that relate to them in some way for example to change text. How can I do this? I dont see any ID attribute. I create button using this code.

ImGui::Begin("Button");
Button("Click me");
End();

I dont see any example in documentation :/

antonim
  • 57
  • 1
  • 5
  • Isn't the point of imguis design that you do things inline? If you want the button to act on something, you need to reference it then and there where the button is created. – super Jan 24 '21 at 13:41

1 Answers1

4

Imgui buttons don't use any id or callbacks. Instead, the ImGui::Button("Clikc me") will return a boolean which is true if the button was clicked. (here is an example)

ImGui::Begin("window");

if (ImGui::Button("Click me")) {
    // onButtonClick();
}

ImGui::End();

for more read https://github.com/ocornut/imgui/tree/master/docs and seeimgui_demo.cpp it has some better examples on how to use it.

thakee nathees
  • 877
  • 1
  • 9
  • 16