Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageButton inside loop #6567

Closed
ParkSeungwon opened this issue Jul 3, 2023 · 1 comment
Closed

ImageButton inside loop #6567

ParkSeungwon opened this issue Jul 3, 2023 · 1 comment
Labels
label/id and id stack implicit identifiers, pushid(), id stack

Comments

@ParkSeungwon
Copy link

ParkSeungwon commented Jul 3, 2023

In case there are Many ImageButtons inside loop, only the first one can be executed when clicked. Is this bug? If I change it to a normal Button , it works fine.

for(int i=0;   i<10; i++ ) {
  if(ImageButton()) {
     cout << i;
  }
}

First button works, prints 0. Other button does not work.

Maybe this is due to same texturID?

@ocornut
Copy link
Owner

ocornut commented Jul 3, 2023

Use PushID() in loops.
This is explained in the FAQ.
https://github.com/ocornut/imgui/blob/master/docs/FAQ.md#q-about-the-id-stack-system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
label/id and id stack implicit identifiers, pushid(), id stack
Projects
None yet
Development

No branches or pull requests

2 participants