Skip to content

CheckBox

Otavio edited this page Jul 23, 2021 · 5 revisions

CheckBox

Introduction:

CheckBox is a widget that permits the user to make a binary choice. In other words if the funtion is enabled or disabled (true or false).

How it works:

When the user checks or unchecks a CheckBox it will return one of 2 states: true or false.

Example:

You will need to declare a pointer for your widget and to initialize it:

std::shared_ptr<FGUI::CCheckBox> CheckBox;

Now you can start setting up your widget usign the Builder Pattern.

FGUI::CBuilder buildrPattern;

// CheckBox
CheckBox = std::make_shared<FGUI::CCheckBox>();
buildrPattern.Widget(CheckBox).Title("Enable").Font("Tahoma", 12, true).SpawnIn(Container);

NOTE: You can also set the default state of a CheckBox before initializing your menu (See: SetState)

(There's other functions of the builder pattern that you can use when setting up a CheckBox

Usage:
// this will check if the CheckBox is checked (true)
if (CheckBox->GetState()) {

  // do stuff

}

// or

// this will set a custom state for the checkbox if Something is true
// you can do much more, those are just some simple examples
if (Something) {

  CheckBox->SetState(true/false);

}

What's next?

Next you will learn about the ColorPicker Widget.