Skip to content

Commit

Permalink
Viewport: Tweaked selection of g.MouseRefViewport, in particular aime…
Browse files Browse the repository at this point in the history
…d at fixing browsing child-menus while holding mouse buttons with menus in multiple viewports. (#1542)
  • Loading branch information
ocornut committed Apr 17, 2018
1 parent 50e453a commit 6ac5063
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3513,12 +3513,13 @@ static void ImGui::UpdateViewports()
g.MouseRefViewport = viewport_ref;
g.MouseRefViewport->LastFrameAsRefViewport = g.FrameCount;

// When dragging something, always refer to the last hovered viewport (so when we are between viewport, our dragged preview will tend to show in the last viewport)
// When dragging something, always refer to the last hovered viewport.
// (So when we are between viewports, our dragged preview will tend to show in the last viewport even if we don't have tooltips in viewports)
// Also consider the case of holding on a menu item to browse child menus: even thought a mouse button is held, there's no active id because menu items only react on mouse release.
const bool is_mouse_dragging_with_an_expected_destination = g.DragDropActive || (g.MovingWindow != NULL);
const bool is_mouse_all_released = !ImGui::IsAnyMouseDown();
if (is_mouse_dragging_with_an_expected_destination || is_mouse_all_released)
if (is_mouse_dragging_with_an_expected_destination || g.ActiveId == 0 || !ImGui::IsAnyMouseDown())
{
if (is_mouse_dragging_with_an_expected_destination)
if (is_mouse_dragging_with_an_expected_destination && viewport_hovered == NULL)
viewport_hovered = g.MouseHoveredLastViewport;
if (viewport_hovered != NULL && viewport_hovered != g.MouseRefViewport && !(viewport_hovered->Flags & ImGuiViewportFlags_NoInputs))
{
Expand Down

0 comments on commit 6ac5063

Please sign in to comment.