Skip to content

Creating checkboxes from a list of values #7472

@duhnyel

Description

@duhnyel

Version/Branch of Dear ImGui:

Version 1.90.4 WIP, Branch: master

Back-ends:

imgui_impl_sdl3.cpp + imgui_impl_sdlrenderer3.cpp

Compiler, OS:

Linux + cmake(ninja + gcc)

Full config/build information:

Dear ImGui 1.90.4 WIP (19031)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=201402
define: __linux__
define: __GNUC__=10
--------------------------------
io.BackendPlatformName: imgui_impl_sdl3
io.BackendRendererName: imgui_impl_sdlrenderer3
io.ConfigFlags: 0x00000003
 NavEnableKeyboard
 NavEnableGamepad
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000000E
 HasMouseCursors
 HasSetMousePos
 RendererHasVtxOffset
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 1280.00,720.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:

I'm trying to create checkboxes from an array of values but for some reason it doesn't set the value of the boolean inside the array. The checkbox just stays blank or quickly flashes checked and the value of the boolean doesn't change. What to do?

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

// here is a snippet to reproduce the issue
// as you can see it doesn't keep the checkbox checked 
bool foo[2] = {false, false};
ImGui::Begin("Hello, world!");                   
for(int i = 0; i < sizeof(foo); i++){
    ImGui::Checkbox("test", &foo[i]);
}
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