Skip to content
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

IsItemDeactivatedAfterEdit Interrupted By Modal Popup #5184

Open
santorac opened this issue Apr 12, 2022 · 1 comment
Open

IsItemDeactivatedAfterEdit Interrupted By Modal Popup #5184

santorac opened this issue Apr 12, 2022 · 1 comment

Comments

@santorac
Copy link

santorac commented Apr 12, 2022

Version/Branch of Dear ImGui:

Version: v1.82
Branch: unknown

Back-end/Renderer/Compiler/OS

Back-ends: working within Open 3D Engine
Compiler: Visual Studio 2019
Operating System: Windows 10

My Issue/Question:

I have a slider and only want to apply the changes after the slider is released, so I'm using IsItemDeactivatedAfterEdit(). If a modal popup is opened while the slider is being dragged, then the slider is deactivated when focus is lost, and IsItemDeactivatedAfterEdit() never returns true. I'd like IsItemDeactivatedAfterEdit() to return true either before the popup is opened (preferably) or after the popup is closed.

Screenshots/Video

IsItemDeactivatedAfterEdit_Interrupted.mp4

Standalone, minimal, complete and verifiable example: (see #2261)

Here is a snippet of test code to demonstrate the issue, place something like this in a per-frame tick function. If you drag and release the slider before the modal popup, then "Applied Count" will be incremented, and "Applied Value" will be updated to the slider value. If you hold the slider until the popup happens, then the value will not be applied.

        static float time = 0.0f;
        time += deltaTime;
        static float testValue = 0.0f;
        static float appliedValue = 0.0f;
        static int applyCounter = 0;
        static const char* modalPopupName = "Interruption";
        if (ImGui::Begin("TEST"))
        {
            ImGui::SliderFloat("Slider", &testValue, 0.0f, 1.0f);
            bool applyChanges = ImGui::IsItemDeactivatedAfterEdit();

            if (applyChanges)
            {
                applyCounter++;
                appliedValue = testValue;
            }
            
            ImGui::LabelText("Applied Count", "%d", applyCounter);
            ImGui::LabelText("Applied Value", "%f", appliedValue);

            if (time > 3.0f)
            {
                ImGui::OpenPopup(modalPopupName);

                if (ImGui::BeginPopupModal(modalPopupName))
                {
                    ImGui::Text("Interrupted!");
                    ImGui::EndPopup();
                }

                if (time > 4.0f)
                {
                    time = 0.0f;
                }
            }
        }
        ImGui::End();
@ocornut
Copy link
Owner

ocornut commented Apr 13, 2022

Thanks for reporting, I can confirm the issue.
While not the same there's a little bit of overlap with #4714 (which I have a 90% fix for, but didn't finish it). I believe the solution for this (#5184) may lead t improving my solution for #4714.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants