-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Begin() to append doesn't set LastItemData for title-bar/tab (was BeginItemTooltip
may react to wrong widgets?)
#7506
Comments
BeginItemTooltip
may react to wrong widgets?BeginItemTooltip
may react to wrong widgets?)
The problem is caused by the fact that on a // We fill last item data based on Title Bar/Tab, in order for IsItemHovered() and IsItemActive() to be usable after Begin().
// This is useful to allow creating context menus on title bar only, etc.
SetLastItemData(window->MoveId, g.CurrentItemFlags, IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false) ? ImGuiItemStatusFlags_HoveredRect : 0, title_bar_rect); Therefore we inherit last value of g.LastItemData.ID & co. There is special handling in We could perfectly compute // When reusing window again multiple times a frame, just append content (don't need to setup again)
if (first_begin_of_the_frame)
{
....
}
else
{
// Append
SetCurrentWindow(window);
ImRect title_bar_rect = window->TitleBarRect();
SetLastItemData(window->MoveId, g.CurrentItemFlags, IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false) ? ImGuiItemStatusFlags_HoveredRect : 0, title_bar_rect);
} That technically also fixes using e.g. IsItemHovered() right after an append-Begin(): ImGui::Begin("Another #7506 issue");
ImGui::End();
ImGui::Begin("Another #7506 issue");
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Hovering title bar!");
ImGui::End(); This is now fixed as well. Actual fix goes through a function as the logic is longer in docking. |
Added a regression test: ocornut/imgui_test_engine@fc5105f |
Version/Branch of Dear ImGui:
Version 1.90.5
Back-ends:
imgui_impl_sdl2.cpp + imgui_impl_sdlrenderer2.cpp
Compiler, OS:
Windows 10 + MSVC 2022
Full config/build information:
No response
Details:
When the window is collapsed,
BeginItemTooltip
may react to the a widget in other windows. (I'm not sure whether I've misused the functions.)Screenshots/Video:
(The title color is irrelevant here.)
Minimal, Complete and Verifiable Example code:
The text was updated successfully, but these errors were encountered: