{"action":"created","issue":{"url":"https://api.github.com/repos/ocornut/imgui/issues/74","repository_url":"https://api.github.com/repos/ocornut/imgui","labels_url":"https://api.github.com/repos/ocornut/imgui/issues/74/labels{/name}","comments_url":"https://api.github.com/repos/ocornut/imgui/issues/74/comments","events_url":"https://api.github.com/repos/ocornut/imgui/issues/74/events","html_url":"https://github.com/ocornut/imgui/issues/74","id":48139821,"number":74,"title":"Buttons with identical labels do not work","user":{"login":"UUSim","id":9439166,"avatar_url":"https://avatars.githubusercontent.com/u/9439166?v=3","gravatar_id":"","url":"https://api.github.com/users/UUSim","html_url":"https://github.com/UUSim","followers_url":"https://api.github.com/users/UUSim/followers","following_url":"https://api.github.com/users/UUSim/following{/other_user}","gists_url":"https://api.github.com/users/UUSim/gists{/gist_id}","starred_url":"https://api.github.com/users/UUSim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UUSim/subscriptions","organizations_url":"https://api.github.com/users/UUSim/orgs","repos_url":"https://api.github.com/users/UUSim/repos","events_url":"https://api.github.com/users/UUSim/events{/privacy}","received_events_url":"https://api.github.com/users/UUSim/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-11-07T22:42:34Z","updated_at":"2016-06-06T00:46:11Z","closed_at":"2014-11-07T23:04:05Z","body":"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.\r\n\r\nOnto the issue:\r\nHaving Buttons with the same label, can cause unpredictable results.\r\nIn my case, with 2 buttons controlling two separate settings:\r\n```\r\nImGui::Text(\"Settting 1:\");\r\nImGui::SameLine();\r\nif (ImGui::Button((setting1enabled) ? \"Yes\" : \"No\")){\r\n\tsetting1enabled = !setting1enabled;\r\n}\r\n\r\nImGui::Text(\"Settting 2:\");\r\nImGui::SameLine();\r\nif (ImGui::Button((setting2enabled) ? \"Yes\" : \"No\")){\r\n\tsetting2enabled = !setting2enabled;\r\n}\r\n```\r\n\r\nIn both settings are `true`, the label is identical (`\"Yes\"`) for both buttons.\r\nWhen the 2nd button is then clicked, `ImGui::Button` will return false because \r\n`window->GetID(label);` (imgui.cpp: line 3076) will return the ID of the 1st item with that label.\r\nSince it will check the mouse coordinates against the coordinates of the wrong button, it will report as not being pressed.\r\n\r\nWhen `setting1enabled = false` (or `setting1enabled != setting2enabled`), the label on each button will be different, and everything works as expected.\r\n\r\nIn case more than two buttons have an identical label, button `Bn` will only respond if the labels of `B0,B1,...,Bn-1 != Bn` (I have not tried this, but this is what will happen most likely). \r\n\r\nIdea for a solution:\r\n- Allow supplying an extra ID to the ImGui::Button function call (ID=-1 by default). \r\n- If the optional ID is given, use that instead of the text label to index the Button in ImGui's storage (hash table?).\r\n\r\nThis problem may also apply to other widgets.\r\nNote: 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 "},"comment":{"url":"https://api.github.com/repos/ocornut/imgui/issues/comments/223848422","html_url":"https://github.com/ocornut/imgui/issues/74#issuecomment-223848422","issue_url":"https://api.github.com/repos/ocornut/imgui/issues/74","id":223848422,"user":{"login":"xaxxon","id":143986,"avatar_url":"https://avatars.githubusercontent.com/u/143986?v=3","gravatar_id":"","url":"https://api.github.com/users/xaxxon","html_url":"https://github.com/xaxxon","followers_url":"https://api.github.com/users/xaxxon/followers","following_url":"https://api.github.com/users/xaxxon/following{/other_user}","gists_url":"https://api.github.com/users/xaxxon/gists{/gist_id}","starred_url":"https://api.github.com/users/xaxxon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xaxxon/subscriptions","organizations_url":"https://api.github.com/users/xaxxon/orgs","repos_url":"https://api.github.com/users/xaxxon/repos","events_url":"https://api.github.com/users/xaxxon/events{/privacy}","received_events_url":"https://api.github.com/users/xaxxon/received_events","type":"User","site_admin":false},"created_at":"2016-06-06T00:46:11Z","updated_at":"2016-06-06T00:46:11Z","body":"The ## trick is neat, but how do you create a label that is unrelated to the ID in any way?   "}}
{"actor":{"display_login":"xaxxon"}}