Imgui: How to enable a checkbox by default?

Created on 8 Oct 2016  路  7Comments  路  Source: ocornut/imgui

Hello, I have been looking around and have found nothing but is there a way to enable a checkbox by default? meaning when I start the imgui the box will be checked as well with the function. C++

ty

Most helpful comment

Are you sure you're not resetting it every time before calling ImGui::CheckBox again? This is usually the case the the most of us aren't used to "immediate mode gui" style of handling variable changes and updates.

All 7 comments

static bool checked = true; Checkbox("checkbox", &checked);

Set the boolean to true before the first time calling Checkbox.

ty
but how do you set the checkbox already checked?

ImGui::Checkbox( charenc( "Watermark" ), &Vars.Misc.Watermark );

I tried

ImGui::Checkbox( charenc( "Watermark" ), &Vars.Misc.Watermark, &checked );

but too many arguments.

but how do you set the checkbox already checked?

Vars.Misc.Watermark = true;

Alright it worked... lol but now I cant uncheck it..

Are you sure you're not resetting it every time before calling ImGui::CheckBox again? This is usually the case the the most of us aren't used to "immediate mode gui" style of handling variable changes and updates.

The bool value is yours.
Checkbox() just toggles it when you click.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KaungZawHtet picture KaungZawHtet  路  3Comments

the-lay picture the-lay  路  3Comments

ILoveImgui picture ILoveImgui  路  3Comments

namuda picture namuda  路  3Comments

spaderthomas picture spaderthomas  路  3Comments