.. default-domain:: cpp .. highlight:: cpp .. namespace:: krpc::services::UI Toggle ====== .. class:: Toggle A control that is either checked or not. Added to a :class:`Canvas` or a :class:`Panel`. .. note:: On its own a toggle is a check box. Put several of them in the same :class:`ToggleGroup` and they become radio buttons, as only one toggle in a group can be checked at a time. | Base class: :class:`InputControl` .. container:: inherited-members .. rubric:: Inherited Members * From :class:`InputControl`: :func:`changed `, :func:`set_changed ` * From :class:`Control`: :func:`interactable `, :func:`set_interactable `, :func:`color `, :func:`set_color `, :func:`tooltip `, :func:`set_tooltip ` * From :class:`Object`: :func:`rect_transform `, :func:`layout_element `, :func:`visible `, :func:`set_visible `, :func:`remove ` .. function:: Text text() The text for the toggle. .. function:: bool checked() .. function:: void set_checked(bool value) Whether the toggle is checked. .. note:: Checking a toggle that belongs to a :class:`ToggleGroup` unchecks the rest of that group, whether or not it is on the screen. .. function:: std::optional group() .. function:: void set_group(std::optional value) The group that the toggle belongs to, or ``NULL`` if it does not belong to one. .. note:: Only one toggle in a group can be checked at a time, so a group turns a set of toggles into radio buttons. A group does not have to contain the toggles, so they can be grouped independently of how they are laid out.