-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Buttons with identical labels do not work #74
Comments
Looking at imgui.cpp line 115ff ( |
Ouch! A very big sorry indeed! I did not see that. For other users making the same mistake (not reading the troubleshooting tips in the cpp that is..), here is the help section covering this issue:
In my case, I used the final option. |
This is indeed a common question especially for first-time users of immediate mode GUI library. |
and use label###ID if you don't want the label to be part of the ID |
This ought to be made automatic by IamGui. Because, it can be a security issue, performance, memory, and a waste of codespace. calling push and pop, and keeping track of id. (Deep nesting issue) If I understand this right, it is queued into the Graphic library for every draw instruction made? |
Signed-off-by: Liyan Zhao <return65535@qq.com>
Also #74, #96, #480, #501, #647, #654, #719, #843, #894, #1057, #1173, #1390, #1414, #1556, #1768, #2041, #2116, #2330, #2475, #2562, #2667, #2807, #2885, #3102, #3375, #3526, #3964, #4008, #4070, #4158, #4172, #4199, #4375, #4395, #4471, #4548, #4612, #4631, #4657, #4796, #5210, #5303, #5360, #5393, #5533, #5692, #5707, #5729, #5773, #5787, #5884, #6046, #6093, #6186, #6223, #6364, #6387, #6567, #6692, #6724, #6939, #6984, #7246, #7270, #7375, #7421, #7434, #7472, #7581, #7724, #7926, #7937 and probably more.. Tagging to increase visibility!
Before rattling any discussion: This could be considered improper usage of ImGui, however in my ignorance I did use ImGui like this. I noticed the issue, and I think you should now about it.
Onto the issue:
Having Buttons with the same label, can cause unpredictable results.
In my case, with 2 buttons controlling two separate settings:
In both settings are
true
, the label is identical ("Yes"
) for both buttons.When the 2nd button is then clicked,
ImGui::Button
will return false becausewindow->GetID(label);
(imgui.cpp: line 3076) will return the ID of the 1st item with that label.Since it will check the mouse coordinates against the coordinates of the wrong button, it will report as not being pressed.
When
setting1enabled = false
(orsetting1enabled != setting2enabled
), the label on each button will be different, and everything works as expected.In case more than two buttons have an identical label, button
Bn
will only respond if the labels ofB0,B1,...,Bn-1 != Bn
(I have not tried this, but this is what will happen most likely).Idea for a solution:
This problem may also apply to other widgets.
Note: You may close this issue I you regard this issue as being unintended library usage. That being said, I think it would be nice if users could choose to use it like this anyway
The text was updated successfully, but these errors were encountered: