.. default-domain:: js .. highlight:: js .. module:: UI :no-index: Toggle ====== .. class:: Toggle A control that is either checked or not. Added to a :class:`UI.Canvas` or a :class:`UI.Panel`. .. note:: On its own a toggle is a check box. Put several of them in the same :class:`UI.ToggleGroup` and they become radio buttons, as only one toggle in a group can be checked at a time. | Base class: :class:`UI.InputControl` .. container:: inherited-members .. rubric:: Inherited Members * From :class:`UI.InputControl`: :meth:`getChanged `, :meth:`setChanged ` * From :class:`UI.Control`: :meth:`getInteractable `, :meth:`setInteractable `, :meth:`getColor `, :meth:`setColor `, :meth:`getTooltip `, :meth:`setTooltip ` * From :class:`UI.Object`: :meth:`getRectTransform `, :meth:`getLayoutElement `, :meth:`getVisible `, :meth:`setVisible `, :meth:`remove ` .. method:: getText() The text for the toggle. :Property: Read-only, cannot be set :rtype: :class:`UI.Text` .. method:: getChecked() setChecked(value) Whether the toggle is checked. :Property: Can be read or written :rtype: ``boolean`` .. note:: Checking a toggle that belongs to a :class:`UI.ToggleGroup` unchecks the rest of that group, whether or not it is on the screen. .. method:: getGroup() setGroup(value) The group that the toggle belongs to, or ``null`` if it does not belong to one. :Property: Can be read or written :rtype: :class:`UI.ToggleGroup` or ``null`` .. 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.