Skip to content

Strange behavior with InputXXX widgets editing stack variables #4714

@BobbyAnguelov

Description

@BobbyAnguelov

Version/Branch of Dear ImGui:

Version: 1.85
Branch: docking

My Issue/Question:

I noticed some strange behavior with imgui when editing stack vars.

In my case, I have a stack var that is set to a copy of a specific variable each frame, I then edit that stack copy with a basic imgui widget. I wish to only change the original value if the widget is deactivated, so I use the IsItemDeactivatedAfterEdit function to detect that and them update the original value.

This doesnt work reliably, if I switch focus to a widget that was declared/submitted BEFORE the active widget, I get the signal the value changed but it actually didn't change the stack var. Now if I change focus to a widget declared after the currently active one everything works as expected. This doesnt seem correct...

I am not hitting return/enter at all, just trying to commit the value via the focus switch/deactivation of the widget.

Screenshots/Video

bandicam.2021-11-11.16-46-56-267.mp4

(sorry about the black frames, video capture on W11 has some issues it seems)

Standalone, minimal, complete and verifiable example:

            ImVec4 v = temp;
            ImGui::Begin( "Example" );

            ImGui::InputFloat( "##f4x", &v.x, 0, 0, "%.3f", 0 );
            if ( ImGui::IsItemDeactivatedAfterEdit() )
            {
                temp = v;
            }

            ImGui::InputFloat( "##f4y", &v.y, 0, 0, "%.3f", 0 );
            if ( ImGui::IsItemDeactivatedAfterEdit() )
            {
                temp = v;
            }

            ImGui::InputFloat( "##f4z", &v.z, 0, 0, "%.3f", 0 );
            if ( ImGui::IsItemDeactivatedAfterEdit() )
            {
                temp = v;
            }

            ImGui::InputFloat( "##f4w", &v.w, 0, 0, "%.3f", 0 );
            if ( ImGui::IsItemDeactivatedAfterEdit() )
            {
                temp = v;
            }
            ImGui::End();

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions