@@ -463,6 +463,9 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
463
463
ImGuiContext& g = *GImGui;
464
464
ImGuiWindow* window = GetCurrentWindow ();
465
465
466
+ bool pressed = false ;
467
+ bool hovered = ItemHoverable (bb, id);
468
+
466
469
if (flags & ImGuiButtonFlags_Disabled)
467
470
{
468
471
if (out_hovered) *out_hovered = false ;
@@ -489,9 +492,6 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
489
492
IMGUI_TEST_ENGINE_ITEM_ADD (bb, id);
490
493
#endif
491
494
492
- bool pressed = false ;
493
- bool hovered = ItemHoverable (bb, id);
494
-
495
495
// Drag source doesn't report as hovered
496
496
if (hovered && g.DragDropActive && g.DragDropPayload .SourceId == id && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoDisableHover))
497
497
hovered = false ;
@@ -1365,7 +1365,7 @@ bool ImGui::SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float
1365
1365
if (g.ActiveId != id)
1366
1366
SetItemAllowOverlap ();
1367
1367
1368
- if (held || (g. HoveredId == id && g.HoveredIdPreviousFrame == id && g.HoveredIdTimer >= hover_visibility_delay))
1368
+ if (held || (hovered && g.HoveredIdPreviousFrame == id && g.HoveredIdTimer >= hover_visibility_delay))
1369
1369
SetMouseCursor (axis == ImGuiAxis_Y ? ImGuiMouseCursor_ResizeNS : ImGuiMouseCursor_ResizeEW);
1370
1370
1371
1371
ImRect bb_render = bb;
@@ -2189,7 +2189,7 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
2189
2189
return TempInputScalar (frame_bb, id, label, data_type, p_data, format);// , p_min, p_max);
2190
2190
2191
2191
// Draw frame
2192
- const ImU32 frame_col = GetColorU32 (g.ActiveId == id ? ImGuiCol_FrameBgActive : g. HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
2192
+ const ImU32 frame_col = GetColorU32 (g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
2193
2193
RenderNavHighlight (frame_bb, id);
2194
2194
RenderFrame (frame_bb.Min , frame_bb.Max , frame_col, true , style.FrameRounding );
2195
2195
@@ -2642,7 +2642,7 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
2642
2642
return TempInputScalar (frame_bb, id, label, data_type, p_data, format);// , p_min, p_max);
2643
2643
2644
2644
// Draw frame
2645
- const ImU32 frame_col = GetColorU32 (g.ActiveId == id ? ImGuiCol_FrameBgActive : g. HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
2645
+ const ImU32 frame_col = GetColorU32 (g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
2646
2646
RenderNavHighlight (frame_bb, id);
2647
2647
RenderFrame (frame_bb.Min , frame_bb.Max , frame_col, true , g.Style .FrameRounding );
2648
2648
@@ -2788,7 +2788,7 @@ bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType d
2788
2788
}
2789
2789
2790
2790
// Draw frame
2791
- const ImU32 frame_col = GetColorU32 (g.ActiveId == id ? ImGuiCol_FrameBgActive : g. HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
2791
+ const ImU32 frame_col = GetColorU32 (g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
2792
2792
RenderNavHighlight (frame_bb, id);
2793
2793
RenderFrame (frame_bb.Min , frame_bb.Max , frame_col, true , g.Style .FrameRounding );
2794
2794
@@ -6347,7 +6347,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
6347
6347
RenderArrow (window->DrawList , pos + ImVec2 (window->DC .MenuColumns .Pos [2 ] + extra_w + g.FontSize * 0 .30f , 0 .0f ), text_col, ImGuiDir_Right);
6348
6348
}
6349
6349
6350
- const bool hovered = enabled && ItemHoverable (window->DC .LastItemRect , id);
6350
+ const bool hovered = ItemHoverable (window->DC .LastItemRect , id) && enabled ;
6351
6351
if (menuset_is_open)
6352
6352
g.NavWindow = backed_nav_window;
6353
6353
@@ -7216,7 +7216,6 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
7216
7216
bool pressed = ButtonBehavior (bb, id, &hovered, &held, button_flags);
7217
7217
if (pressed)
7218
7218
tab_bar->NextSelectedTabId = id;
7219
- hovered |= (g.HoveredId == id);
7220
7219
7221
7220
// Allow the close button to overlap unless we are dragging (in which case we don't want any overlapping tabs to be hovered)
7222
7221
if (!held)
@@ -7281,7 +7280,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
7281
7280
7282
7281
// Tooltip (FIXME: Won't work over the close button because ItemOverlap systems messes up with HoveredIdTimer)
7283
7282
// We test IsItemHovered() to discard e.g. when another item is active or drag and drop over the tab bar (which g.HoveredId ignores)
7284
- if (g. HoveredId == id && !held && g.HoveredIdNotActiveTimer > 0 .50f && IsItemHovered ())
7283
+ if (hovered && !held && g.HoveredIdNotActiveTimer > 0 .50f && IsItemHovered ())
7285
7284
if (!(tab_bar->Flags & ImGuiTabBarFlags_NoTooltip) && !(tab->Flags & ImGuiTabItemFlags_NoTooltip))
7286
7285
SetTooltip (" %.*s" , (int )(FindRenderedTextEnd (label) - label), label);
7287
7286
0 commit comments