imgui
imgui copied to clipboard
Item-tooltip for group will disappear for a short time if the widget inside is clicked
Version/Branch of Dear ImGui:
Version 1.90.9
Back-ends:
imgui_impl_sdl2.cpp + imgui_impl_sdlrenderer2.cpp
Compiler, OS:
Windows 10 + MSVC 2022
Full config/build information:
No response
Details:
If an item in a group is clicked, IsItemHovered for the group will become false for a short period of time. (This will happen even if there is only one widget in the group.)
Screenshots/Video:
Minimal, Complete and Verifiable Example code:
static void issue() {
if (ImGui::Begin("Issue", 0, ImGuiWindowFlags_NoSavedSettings)) {
ImGui::BeginGroup();
ImGui::Button("Button1");
ImGui::SameLine();
ImGui::Button("Button2");
ImGui::EndGroup();
const bool hovered = ImGui::IsItemHovered();
const bool tooltip_hovered = ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip);
// `ImGuiHoveredFlags_DelayNormal` alone have no such issue, but will behave the same if added `ImGuiHoveredFlags_NoSharedDelay`.
// The use case that the raised issue.
const ImVec2 min = ImGui::GetItemRectMin();
const ImVec2 max = ImGui::GetItemRectMax();
ImGui::GetWindowDrawList()->AddRect(min, max, IM_COL32_WHITE);
if (ImGui::BeginItemTooltip()) {
ImGui::Text("These buttons ...");
ImGui::EndTooltip();
}
// `Tooltip-hovered` will become 0 for a short period when the button is either clicked or
// released-from)
ImGui::Text("\n\n\nMouse:%d,Hovered:%d Tooltip-hovered:%d", int(ImGui::IsMouseDown(ImGuiMouseButton_Left)),
int(hovered), int(tooltip_hovered));
}
ImGui::End();
}
Groups are unfortunately flawed in various ways, and one of the thing is they inherit the id of the active item inside them so the id can change. I should rework this eventually but probably not soon.