DragFloat loses focus while dragging in submenu, if mouse goes over parent menu #6869

Closed
opened 2023-09-27 12:59:08 +00:00 by outsiderwork · 1 comment
outsiderwork commented 2023-09-27 12:59:08 +00:00 (Migrated from github.com)

Version: 1.90 wip (18993)
Branch: master

Back-end/Renderer/Compiler/OS

Renderer: All
OS: only tested on Windows 10

My Issue/Question:

When I change the value of a DragFloat in a submenu, by dragging the mouse, the slider loses focus when mouse goes over the parent menu, but not when going outside the submenu onto the window.
This also does not happen if the DragFloat is on a window.

I ran the examples, and I can see the issue in the "Dear ImGui Demo" window, in Menu > Options > Value slider.

Screenshots/Video

https://github.com/ocornut/imgui/assets/142992139/2e78d982-6bea-465b-a3ee-3e82e318fabd

Standalone, minimal, complete and verifiable example:

Running the examples I built from master.

Version: 1.90 wip (18993) Branch: master **Back-end/Renderer/Compiler/OS** Renderer: All OS: only tested on Windows 10 **My Issue/Question:** When I change the value of a DragFloat in a submenu, by dragging the mouse, the slider loses focus when mouse goes over the parent menu, but not when going outside the submenu onto the window. This also does not happen if the DragFloat is on a window. I ran the examples, and I can see the issue in the "Dear ImGui Demo" window, in Menu > Options > Value slider. **Screenshots/Video** https://github.com/ocornut/imgui/assets/142992139/2e78d982-6bea-465b-a3ee-3e82e318fabd **Standalone, minimal, complete and verifiable example:** Running the examples I built from master.
ocornut commented 2023-09-27 14:35:54 +00:00 (Migrated from github.com)

Confirmed as caused by 0dec430. I'm surprised it hasn't been reported earlier.

The cross-menu hovering system has been one of my nemesis for a long time (spent many days of work trying to find a design that made sense and validating with tests), but it turns out that, luckily this specific bug is more due to an overlooked thing rather than a bigger design flaw.

Effectively an Active ID would prevent hovering and the code prior to 0dec430 did benefit from that.
Pushed fix 456aa3b + regression test:
ocornut/imgui_test_engine@68d9f57479

        // Verify that menu doesn't close while activating an item and dragging back over parent menu (#6869)
        ctx->ItemClose("Popups & Modal windows");
        ctx->MenuClick("Menu");
        ctx->MouseMove("//$FOCUSED/New");
        ImVec2 pos = ImGui::GetMousePos();
        ctx->MenuClick("Menu/Options/Value"); // Click DragFloat()
        ctx->MouseDown();
        ctx->Yield();
        IM_CHECK_EQ(g.OpenPopupStack.Size, 2);
        IM_CHECK_EQ(g.ActiveId, ctx->GetID("//$FOCUSED/Value"));
#if IMGUI_VERSION_NUM >= 18993
        ctx->MouseMoveToPos(pos); // Move back to "New" item
        IM_CHECK_EQ(g.OpenPopupStack.Size, 2);
        IM_CHECK_EQ(g.ActiveId, ctx->GetID("//$FOCUSED/Value"));
#endif

Thank you for reporting!

Confirmed as caused by 0dec430. I'm surprised it hasn't been reported earlier. The cross-menu hovering system has been one of my nemesis for a long time (spent many days of work trying to find a design that made sense and validating with tests), but it turns out that, luckily this specific bug is more due to an overlooked thing rather than a bigger design flaw. Effectively an Active ID would prevent hovering and the code prior to 0dec430 did benefit from that. Pushed fix 456aa3b + regression test: https://github.com/ocornut/imgui_test_engine/commit/68d9f57479c4bd536604292a454b559873ba7990 ```cpp // Verify that menu doesn't close while activating an item and dragging back over parent menu (#6869) ctx->ItemClose("Popups & Modal windows"); ctx->MenuClick("Menu"); ctx->MouseMove("//$FOCUSED/New"); ImVec2 pos = ImGui::GetMousePos(); ctx->MenuClick("Menu/Options/Value"); // Click DragFloat() ctx->MouseDown(); ctx->Yield(); IM_CHECK_EQ(g.OpenPopupStack.Size, 2); IM_CHECK_EQ(g.ActiveId, ctx->GetID("//$FOCUSED/Value")); #if IMGUI_VERSION_NUM >= 18993 ctx->MouseMoveToPos(pos); // Move back to "New" item IM_CHECK_EQ(g.OpenPopupStack.Size, 2); IM_CHECK_EQ(g.ActiveId, ctx->GetID("//$FOCUSED/Value")); #endif ``` Thank you for reporting!
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#6869
No description provided.