Skip to content

IsItemEdited on a group doesn't work for edited Checkbox and Selectable widgets inside that group #9028

@PrismaticFlower

Description

@PrismaticFlower

Version/Branch of Dear ImGui:

Version 1.92.4, Branch: master

Back-ends:

imgui_impl_win32.cpp + Custom Renderer Backend

Compiler, OS:

Windows 10 + MSVC 2022

Full config/build information:

Dear ImGui 1.92.4 (19240)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=202004
define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS
define: IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS
define: _WIN32
define: _WIN64
define: _MSC_VER=1941
define: _MSVC_LANG=202004
--------------------------------
io.BackendPlatformName: imgui_impl_win32
io.BackendRendererName: imgui_impl_rhi
io.ConfigFlags: 0x00000020
 NoMouseCursorChange
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000001E
 HasMouseCursors
 HasSetMousePos
 RendererHasVtxOffset
 RendererHasTextures
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,128
io.Fonts->FontLoaderName: FreeType
io.DisplaySize: 2560.00,1377.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Details:

After editing a Checkbox() or Selectable() inside a BeginGroup() and EndGroup() pair IsItemEdited() does not return true after EndGroup(). Other widgets inside a group like SliderInt() do cause IsItemEdited() to return true after EndGroup().

This can be worked around easily by using the return values of Checkbox() and Selectable(). I figured I'd open an issue though to hopefully save anyone else hitting the same thing some time.

bool group_edited = false;

ImGui::BeginGroup();

group_edited |= ImGui::Checkbox("Checkbox", &checkbox_value);
group_edited |= ImGui::Selectable("Selectable", &selectable_value);

ImGui::EndGroup();

group_edited |= ImGui::IsItemEdited();

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

static bool checkbox_value = false;
static bool selectable_value = false;
static bool group_edited = false;

ImGui::Begin("Window");

ImGui::BeginGroup();

ImGui::Checkbox("Checkbox", &checkbox_value);
ImGui::Selectable("Selectable", &selectable_value);

ImGui::EndGroup();

group_edited |= ImGui::IsItemEdited();

if (group_edited)
   ImGui::Text("Group has been edited."); // This branch will never be entered.
else
   ImGui::Text("Group has not been edited.");

ImGui::End();

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions