imgui icon indicating copy to clipboard operation
imgui copied to clipboard

MixedValue item flag for DragScalars

Open theOtherMichael opened this issue 2 years ago • 2 comments

This PR implements the WIP item flag ImGuiItemFlags_MixedValue for drag scalars. When this flag is set, drag scalars will show a "-" to indicate a mixed value, and report a change even when typing the original value into the box.

MixedDragScalars

Use this flag to indicate the drag scalar currently represents multiple values. The following code sample shows how to use it:

#include "imgui.h"
#include "imgui_internal.h"

// ...

void OnGui()
{
    static bool isMixed = true;
    static float fVal   = 0.0f;

    if (isMixed)
    {
        ImGui::PushItemFlag(ImGuiItemFlags_MixedValue, true);

        if (ImGui::DragFloat("Example", &fVal))
        {
            isMixed = false;
        }

        ImGui::PopItemFlag();
    }
    else
    {
        ImGui::DragFloat("Example", &fVal);
    }
}

This works for anything based on DragScalar() (DragFloat(), DragInt4(), etc.).

theOtherMichael avatar Sep 12 '22 17:09 theOtherMichael