class_scrollcontainer.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/ScrollContainer.xml.
  6. .. _class_ScrollContainer:
  7. ScrollContainer
  8. ===============
  9. **Inherits:** :ref:`Container<class_Container>` **<** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`EditorInspector<class_EditorInspector>`
  11. A helper node for displaying scrollable elements such as lists.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. A ScrollContainer node meant to contain a :ref:`Control<class_Control>` child.
  16. ScrollContainers will automatically create a scrollbar child (:ref:`HScrollBar<class_HScrollBar>`, :ref:`VScrollBar<class_VScrollBar>`, or both) when needed and will only draw the Control within the ScrollContainer area. Scrollbars will automatically be drawn at the right (for vertical) or bottom (for horizontal) and will enable dragging to move the viewable Control (and its children) within the ScrollContainer. Scrollbars will also automatically resize the grabber based on the :ref:`Control.custom_minimum_size<class_Control_property_custom_minimum_size>` of the Control relative to the ScrollContainer.
  17. Works great with a :ref:`Panel<class_Panel>` control. You can set :ref:`Control.SIZE_EXPAND<class_Control_constant_SIZE_EXPAND>` on the children's size flags, so they will upscale to the ScrollContainer's size if it's larger (scroll is invisible for the chosen dimension).
  18. .. rst-class:: classref-introduction-group
  19. Tutorials
  20. ---------
  21. - :doc:`GUI containers <../tutorials/ui/gui_containers>`
  22. .. rst-class:: classref-reftable-group
  23. Properties
  24. ----------
  25. .. table::
  26. :widths: auto
  27. +----------------------------------------------------+--------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  28. | :ref:`bool<class_bool>` | clip_contents | ``true`` (overrides :ref:`Control<class_Control_property_clip_contents>`) |
  29. +----------------------------------------------------+--------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  30. | :ref:`bool<class_bool>` | :ref:`follow_focus<class_ScrollContainer_property_follow_focus>` | ``false`` |
  31. +----------------------------------------------------+--------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  32. | :ref:`ScrollMode<enum_ScrollContainer_ScrollMode>` | :ref:`horizontal_scroll_mode<class_ScrollContainer_property_horizontal_scroll_mode>` | ``1`` |
  33. +----------------------------------------------------+--------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  34. | :ref:`int<class_int>` | :ref:`scroll_deadzone<class_ScrollContainer_property_scroll_deadzone>` | ``0`` |
  35. +----------------------------------------------------+--------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  36. | :ref:`int<class_int>` | :ref:`scroll_horizontal<class_ScrollContainer_property_scroll_horizontal>` | ``0`` |
  37. +----------------------------------------------------+--------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  38. | :ref:`int<class_int>` | :ref:`scroll_vertical<class_ScrollContainer_property_scroll_vertical>` | ``0`` |
  39. +----------------------------------------------------+--------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  40. | :ref:`ScrollMode<enum_ScrollContainer_ScrollMode>` | :ref:`vertical_scroll_mode<class_ScrollContainer_property_vertical_scroll_mode>` | ``1`` |
  41. +----------------------------------------------------+--------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  42. .. rst-class:: classref-reftable-group
  43. Methods
  44. -------
  45. .. table::
  46. :widths: auto
  47. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`ensure_control_visible<class_ScrollContainer_method_ensure_control_visible>` **(** :ref:`Control<class_Control>` control **)** |
  49. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`HScrollBar<class_HScrollBar>` | :ref:`get_h_scroll_bar<class_ScrollContainer_method_get_h_scroll_bar>` **(** **)** |
  51. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`VScrollBar<class_VScrollBar>` | :ref:`get_v_scroll_bar<class_ScrollContainer_method_get_v_scroll_bar>` **(** **)** |
  53. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  54. .. rst-class:: classref-reftable-group
  55. Theme Properties
  56. ----------------
  57. .. table::
  58. :widths: auto
  59. +---------------------------------+-------------------------------------------------------+
  60. | :ref:`StyleBox<class_StyleBox>` | :ref:`panel<class_ScrollContainer_theme_style_panel>` |
  61. +---------------------------------+-------------------------------------------------------+
  62. .. rst-class:: classref-section-separator
  63. ----
  64. .. rst-class:: classref-descriptions-group
  65. Signals
  66. -------
  67. .. _class_ScrollContainer_signal_scroll_ended:
  68. .. rst-class:: classref-signal
  69. **scroll_ended** **(** **)**
  70. Emitted when scrolling stops.
  71. .. rst-class:: classref-item-separator
  72. ----
  73. .. _class_ScrollContainer_signal_scroll_started:
  74. .. rst-class:: classref-signal
  75. **scroll_started** **(** **)**
  76. Emitted when scrolling is started.
  77. .. rst-class:: classref-section-separator
  78. ----
  79. .. rst-class:: classref-descriptions-group
  80. Enumerations
  81. ------------
  82. .. _enum_ScrollContainer_ScrollMode:
  83. .. rst-class:: classref-enumeration
  84. enum **ScrollMode**:
  85. .. _class_ScrollContainer_constant_SCROLL_MODE_DISABLED:
  86. .. rst-class:: classref-enumeration-constant
  87. :ref:`ScrollMode<enum_ScrollContainer_ScrollMode>` **SCROLL_MODE_DISABLED** = ``0``
  88. Scrolling disabled, scrollbar will be invisible.
  89. .. _class_ScrollContainer_constant_SCROLL_MODE_AUTO:
  90. .. rst-class:: classref-enumeration-constant
  91. :ref:`ScrollMode<enum_ScrollContainer_ScrollMode>` **SCROLL_MODE_AUTO** = ``1``
  92. Scrolling enabled, scrollbar will be visible only if necessary, i.e. container's content is bigger than the container.
  93. .. _class_ScrollContainer_constant_SCROLL_MODE_SHOW_ALWAYS:
  94. .. rst-class:: classref-enumeration-constant
  95. :ref:`ScrollMode<enum_ScrollContainer_ScrollMode>` **SCROLL_MODE_SHOW_ALWAYS** = ``2``
  96. Scrolling enabled, scrollbar will be always visible.
  97. .. _class_ScrollContainer_constant_SCROLL_MODE_SHOW_NEVER:
  98. .. rst-class:: classref-enumeration-constant
  99. :ref:`ScrollMode<enum_ScrollContainer_ScrollMode>` **SCROLL_MODE_SHOW_NEVER** = ``3``
  100. Scrolling enabled, scrollbar will be hidden.
  101. .. rst-class:: classref-section-separator
  102. ----
  103. .. rst-class:: classref-descriptions-group
  104. Property Descriptions
  105. ---------------------
  106. .. _class_ScrollContainer_property_follow_focus:
  107. .. rst-class:: classref-property
  108. :ref:`bool<class_bool>` **follow_focus** = ``false``
  109. .. rst-class:: classref-property-setget
  110. - void **set_follow_focus** **(** :ref:`bool<class_bool>` value **)**
  111. - :ref:`bool<class_bool>` **is_following_focus** **(** **)**
  112. If ``true``, the ScrollContainer will automatically scroll to focused children (including indirect children) to make sure they are fully visible.
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_ScrollContainer_property_horizontal_scroll_mode:
  116. .. rst-class:: classref-property
  117. :ref:`ScrollMode<enum_ScrollContainer_ScrollMode>` **horizontal_scroll_mode** = ``1``
  118. .. rst-class:: classref-property-setget
  119. - void **set_horizontal_scroll_mode** **(** :ref:`ScrollMode<enum_ScrollContainer_ScrollMode>` value **)**
  120. - :ref:`ScrollMode<enum_ScrollContainer_ScrollMode>` **get_horizontal_scroll_mode** **(** **)**
  121. Controls whether horizontal scrollbar can be used and when it should be visible. See :ref:`ScrollMode<enum_ScrollContainer_ScrollMode>` for options.
  122. .. rst-class:: classref-item-separator
  123. ----
  124. .. _class_ScrollContainer_property_scroll_deadzone:
  125. .. rst-class:: classref-property
  126. :ref:`int<class_int>` **scroll_deadzone** = ``0``
  127. .. rst-class:: classref-property-setget
  128. - void **set_deadzone** **(** :ref:`int<class_int>` value **)**
  129. - :ref:`int<class_int>` **get_deadzone** **(** **)**
  130. Deadzone for touch scrolling. Lower deadzone makes the scrolling more sensitive.
  131. .. rst-class:: classref-item-separator
  132. ----
  133. .. _class_ScrollContainer_property_scroll_horizontal:
  134. .. rst-class:: classref-property
  135. :ref:`int<class_int>` **scroll_horizontal** = ``0``
  136. .. rst-class:: classref-property-setget
  137. - void **set_h_scroll** **(** :ref:`int<class_int>` value **)**
  138. - :ref:`int<class_int>` **get_h_scroll** **(** **)**
  139. The current horizontal scroll value.
  140. .. rst-class:: classref-item-separator
  141. ----
  142. .. _class_ScrollContainer_property_scroll_vertical:
  143. .. rst-class:: classref-property
  144. :ref:`int<class_int>` **scroll_vertical** = ``0``
  145. .. rst-class:: classref-property-setget
  146. - void **set_v_scroll** **(** :ref:`int<class_int>` value **)**
  147. - :ref:`int<class_int>` **get_v_scroll** **(** **)**
  148. The current vertical scroll value.
  149. .. rst-class:: classref-item-separator
  150. ----
  151. .. _class_ScrollContainer_property_vertical_scroll_mode:
  152. .. rst-class:: classref-property
  153. :ref:`ScrollMode<enum_ScrollContainer_ScrollMode>` **vertical_scroll_mode** = ``1``
  154. .. rst-class:: classref-property-setget
  155. - void **set_vertical_scroll_mode** **(** :ref:`ScrollMode<enum_ScrollContainer_ScrollMode>` value **)**
  156. - :ref:`ScrollMode<enum_ScrollContainer_ScrollMode>` **get_vertical_scroll_mode** **(** **)**
  157. Controls whether vertical scrollbar can be used and when it should be visible. See :ref:`ScrollMode<enum_ScrollContainer_ScrollMode>` for options.
  158. .. rst-class:: classref-section-separator
  159. ----
  160. .. rst-class:: classref-descriptions-group
  161. Method Descriptions
  162. -------------------
  163. .. _class_ScrollContainer_method_ensure_control_visible:
  164. .. rst-class:: classref-method
  165. void **ensure_control_visible** **(** :ref:`Control<class_Control>` control **)**
  166. Ensures the given ``control`` is visible (must be a direct or indirect child of the ScrollContainer). Used by :ref:`follow_focus<class_ScrollContainer_property_follow_focus>`.
  167. \ **Note:** This will not work on a node that was just added during the same frame. If you want to scroll to a newly added child, you must wait until the next frame using :ref:`SceneTree.process_frame<class_SceneTree_signal_process_frame>`:
  168. ::
  169. add_child(child_node)
  170. await get_tree().process_frame
  171. ensure_control_visible(child_node)
  172. .. rst-class:: classref-item-separator
  173. ----
  174. .. _class_ScrollContainer_method_get_h_scroll_bar:
  175. .. rst-class:: classref-method
  176. :ref:`HScrollBar<class_HScrollBar>` **get_h_scroll_bar** **(** **)**
  177. Returns the horizontal scrollbar :ref:`HScrollBar<class_HScrollBar>` of this **ScrollContainer**.
  178. \ **Warning:** This is a required internal node, removing and freeing it may cause a crash. If you wish to disable or hide a scrollbar, you can use :ref:`horizontal_scroll_mode<class_ScrollContainer_property_horizontal_scroll_mode>`.
  179. .. rst-class:: classref-item-separator
  180. ----
  181. .. _class_ScrollContainer_method_get_v_scroll_bar:
  182. .. rst-class:: classref-method
  183. :ref:`VScrollBar<class_VScrollBar>` **get_v_scroll_bar** **(** **)**
  184. Returns the vertical scrollbar :ref:`VScrollBar<class_VScrollBar>` of this **ScrollContainer**.
  185. \ **Warning:** This is a required internal node, removing and freeing it may cause a crash. If you wish to disable or hide a scrollbar, you can use :ref:`vertical_scroll_mode<class_ScrollContainer_property_vertical_scroll_mode>`.
  186. .. rst-class:: classref-section-separator
  187. ----
  188. .. rst-class:: classref-descriptions-group
  189. Theme Property Descriptions
  190. ---------------------------
  191. .. _class_ScrollContainer_theme_style_panel:
  192. .. rst-class:: classref-themeproperty
  193. :ref:`StyleBox<class_StyleBox>` **panel**
  194. The background :ref:`StyleBox<class_StyleBox>` of the **ScrollContainer**.
  195. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  196. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  197. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  198. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  199. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  200. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`