Skip to content

Commit

Permalink
RangeSelect/MultiSelect: amend determination of scope_hovered to fix …
Browse files Browse the repository at this point in the history
…for decorated/non-child windows. (7424)
  • Loading branch information
ocornut committed Apr 18, 2024
1 parent 207ebd2 commit a304677
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion imgui_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7262,13 +7262,15 @@ ImGuiMultiSelectIO* ImGui::EndMultiSelect()

// Clear selection when clicking void?
// We specifically test for IsMouseDragPastThreshold(0) == false to allow box-selection!
bool scope_hovered = IsWindowHovered();
// The InnerRect test is necessary for non-child/decorated windows.
bool scope_hovered = IsWindowHovered() && window->InnerRect.Contains(g.IO.MousePos);
if (scope_hovered && (ms->Flags & ImGuiMultiSelectFlags_ScopeRect))
scope_hovered &= scope_rect.Contains(g.IO.MousePos);
if (scope_hovered && g.HoveredId == 0 && g.ActiveId == 0)
{
if (ms->Flags & ImGuiMultiSelectFlags_BoxSelect)
{
// FIXME-MULTISELECT: Stealing HoverId for full scope prevents moving windows (ok) but also prevents focusing from happening. Also steals NavId.
if (!g.BoxSelectState.IsActive && !g.BoxSelectState.IsStarting && g.IO.MouseClickedCount[0] == 1)
BoxSelectStartDrag(ms->BoxSelectId, ImGuiSelectionUserData_Invalid);
SetHoveredID(ms->BoxSelectId);
Expand Down

0 comments on commit a304677

Please sign in to comment.