-
-
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
ImageButton does not responds to click in certain situations #4471
Comments
You likely have an ID conflict. There is a known flaw with You can surround your ImageButton() calls with PushID/PopID() calls, or use |
Thank you for your answer. |
FYI the old For reference: #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
// Legacy API obsoleted in 1.89. Two differences with new ImageButton()
// - old ImageButton() used ImTextureId as item id (created issue with multiple buttons with same image, transient texture id values, opaque computation of ID)
// - new ImageButton() requires an explicit 'const char* str_id'
// - old ImageButton() had frame_padding' override argument.
// - new ImageButton() always use style.FramePadding.
bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, int frame_padding, const ImVec4& bg_col, const ImVec4& tint_col)
{
// Default to using texture ID as ID. User can still push string/integer prefixes.
PushID((void*)(intptr_t)user_texture_id);
if (frame_padding >= 0)
PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2((float)frame_padding, (float)frame_padding));
bool ret = ImageButton("", user_texture_id, size, uv0, uv1, bg_col, tint_col);
if (frame_padding >= 0)
PopStyleVar();
PopID();
return ret;
}
#endif // #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS |
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!
My Issue/Question:
We have an application to manage meshes and materials in scenes. We show the hirarchy of the scene in a docked window and a sort of tree widget we had using the old column system. We noticed that with scenes with several meshes (50+) sometimes buttons to hide/lock the mesh did not work in this docked window even though it did not happen anywhere else. I thought maybe it was time to upgrade so I passed the column system to the tree widget system in the new version but keeps happening. It's not a problem with code because it just simply that you click some buttons and it returns false. The buttons are Imgui::ImageButton.
I could not reproduce writing a simple example but I will upload it just in case you want to see the structure of the gui that is more or less the same.
While I was writing the example I remembered the ImGui::IsItemClicked function, and when I use it after the ImageButton it responds correctly to my click so that is the workaround I'm using right now, but I thought it would be useful to inform about the issue.
Screenshots/Video
2021-08-20.08-58-02.mp4
Standalone, minimal, complete and verifiable example: (see #2261)
imgui-docking.zip
The text was updated successfully, but these errors were encountered: