Skip to content

Checkbox

A control providing the user with an on/off choice.

In contrast to Switch, Checkbox is commonly used in scenarios where the user's on or off choice does not take effect immediately and an additional confirmation is required for the setting to take effect, e.g. by pushing an OK button.

If the target platform does not provide a native checkbox widget, a platform-specific substitution provided by the framework will be displayed instead.

Declaration

namespace bdn::ui {
    class Checkbox : public View
}

Example

#include <bdn/ui/Checkbox.h>
// ...
auto checkbox = std::make_shared<Checkbox>();
checkbox->label = "Click me!";
checkbox->state = TriState::on;
checkbox->onClick() += [](auto event) {
  // Do something on submit
};

Properties

  • Property<std::string> label

    The checkbox's label.

  • Property<TriState> state

    A TriState representing the checkbox's state. Note that Android does not support mixed state checkboxes. Checkboxes in mixed state will be displayed as off on Android.

  • Property<bool> checked

    A boolean representing the checkbox's state. It mirrors and updates the state property when changed.

Events

  • Notifier<const ClickEvent &> &onClick()

    A notifier for click events. Subscribe to this notifier if you want to be notified when the user clicks the checkbox.

Relationships

Inherits from View.

Source

Checkbox.h