.. default-domain:: lua .. highlight:: lua .. currentmodule:: UI Canvas ====== .. class:: Canvas A canvas for user interface elements. See :attr:`UI.stock_canvas ` and :meth:`UI.add_canvas`. .. attribute:: rect_transform: UI.RectTransform The rect transform for the UI object. :Attribute: Read-only, cannot be set :rtype: :class:`UI.RectTransform` .. attribute:: layout_element: UI.LayoutElement How much space the UI object asks a layout for. :Attribute: Read-only, cannot be set :rtype: :class:`UI.LayoutElement` .. note:: Only has an effect when the object is in a panel that has a layout. A canvas is not inside a layout and does not have one. .. attribute:: visible: boolean Whether the UI object is visible. :Attribute: Can be read or written :rtype: boolean .. note:: This is the object's own setting, which is what it was last set to. An object is only drawn when everything it is inside is visible as well, so an interface can be built with its parts visible, inside a panel that is not, and shown all at once by making that panel visible. .. method:: add_panel([visible = true]) Create a panel within this object. :param boolean visible: Whether the new panel is visible. :rtype: :class:`UI.Panel` .. method:: add_text(content, [visible = true]) Add text to this object. :param string content: The text. :param boolean visible: Whether the text is visible. :rtype: :class:`UI.Text` .. method:: add_input_field([visible = true]) Add an input field to this object. :param boolean visible: Whether the input field is visible. :rtype: :class:`UI.InputField` .. method:: add_button(content, [visible = true]) Add a button to this object. :param string content: The label for the button. :param boolean visible: Whether the button is visible. :rtype: :class:`UI.Button` .. method:: add_toggle(content, [visible = true]) Add a toggle to this object. :param string content: The label for the toggle. :param boolean visible: Whether the toggle is visible. :rtype: :class:`UI.Toggle` .. method:: add_toggle_group() Add a toggle group to this object, to make a set of toggles into radio buttons. :rtype: :class:`UI.ToggleGroup` .. note:: The group is not drawn and does not take up any space. The toggles that belong to it can be added anywhere. .. method:: add_slider([vertical = false], [visible = true]) Add a slider to this object. :param boolean vertical: Whether the slider runs from bottom to top, rather than from left to right. :param boolean visible: Whether the slider is visible. :rtype: :class:`UI.Slider` .. method:: add_dropdown([visible = true]) Add a dropdown to this object. :param boolean visible: Whether the dropdown is visible. :rtype: :class:`UI.Dropdown` .. method:: add_image([visible = true]) Add an image to this object. :param boolean visible: Whether the image is visible. :rtype: :class:`UI.Image` .. method:: add_scroll_view([visible = true]) Add a scroll view to this object. :param boolean visible: Whether the scroll view is visible. :rtype: :class:`UI.ScrollView` .. method:: remove() Remove the UI object.