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

Two or more buttons with the same caption, only the very first could be triggered #501

Closed
YukinoHayakawa opened this issue Jan 22, 2016 · 4 comments
Labels
label/id and id stack implicit identifiers, pushid(), id stack

Comments

@YukinoHayakawa
Copy link

For example,

ImGui::Text("ObjectA");
if(ImGui::Button("Remove")) remove(0);
ImGui::Text("ObjectB");
if(ImGui::Button("Remove")) remove(1);

remove() will never be called with 1, even if it is wrapper in a CollapsingHeader.

@Flix01
Copy link

Flix01 commented Jan 22, 2016

   - When passing a label you can optionally specify extra unique ID information within string itself. This helps solving the simpler collision cases.
     use "##" to pass a complement to the ID that won't be visible to the end-user:
       Button("Play");         // Label = "Play",   ID = hash of "Play"
       Button("Play##foo1");   // Label = "Play",   ID = hash of "Play##foo1" (different from above)
       Button("Play##foo2");   // Label = "Play",   ID = hash of "Play##foo2" (different from above)

@ocornut
Copy link
Owner

ocornut commented Jan 22, 2016

Read the FAQ please.

@ocornut ocornut closed this as completed Jan 22, 2016
@jarikomppa
Copy link

Please read FAQ (and well, all documentation) in
https://github.com/ocornut/imgui/blob/master/imgui.cpp

On Friday, January 22, 2016, Flix notifications@github.com wrote:

  • When passing a label you can optionally specify extra unique ID information within string itself. This helps solving the simpler collision cases.
    use "##" to pass a complement to the ID that won't be visible to the end-user: Button("Play"); // Label = "Play", ID = hash of "Play" Button("Play##foo1"); // Label = "Play", ID = hash of "Play##foo1" (different from above) Button("Play##foo2"); // Label = "Play", ID = hash of "Play##foo2" (different from above)


Reply to this email directly or view it on GitHub
#501 (comment).

@YukinoHayakawa
Copy link
Author

well you guys act really quick. thank you.

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

4 participants