class_scrollcontainer.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/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. 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.rect_min_size<class_Control_property_rect_min_size>` of the Control relative to the ScrollContainer. Works great with a :ref:`Panel<class_Panel>` control. You can set ``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).
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - :doc:`GUI containers <../tutorials/ui/gui_containers>`
  20. .. rst-class:: classref-reftable-group
  21. Properties
  22. ----------
  23. .. table::
  24. :widths: auto
  25. +-------------------------+--------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  26. | :ref:`bool<class_bool>` | :ref:`follow_focus<class_ScrollContainer_property_follow_focus>` | ``false`` |
  27. +-------------------------+--------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  28. | :ref:`bool<class_bool>` | rect_clip_content | ``true`` (overrides :ref:`Control<class_Control_property_rect_clip_content>`) |
  29. +-------------------------+--------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  30. | :ref:`int<class_int>` | :ref:`scroll_deadzone<class_ScrollContainer_property_scroll_deadzone>` | ``0`` |
  31. +-------------------------+--------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  32. | :ref:`int<class_int>` | :ref:`scroll_horizontal<class_ScrollContainer_property_scroll_horizontal>` | ``0`` |
  33. +-------------------------+--------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  34. | :ref:`bool<class_bool>` | :ref:`scroll_horizontal_enabled<class_ScrollContainer_property_scroll_horizontal_enabled>` | ``true`` |
  35. +-------------------------+--------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  36. | :ref:`int<class_int>` | :ref:`scroll_vertical<class_ScrollContainer_property_scroll_vertical>` | ``0`` |
  37. +-------------------------+--------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  38. | :ref:`bool<class_bool>` | :ref:`scroll_vertical_enabled<class_ScrollContainer_property_scroll_vertical_enabled>` | ``true`` |
  39. +-------------------------+--------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  40. .. rst-class:: classref-reftable-group
  41. Methods
  42. -------
  43. .. table::
  44. :widths: auto
  45. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`ensure_control_visible<class_ScrollContainer_method_ensure_control_visible>` **(** :ref:`Control<class_Control>` control **)** |
  47. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`HScrollBar<class_HScrollBar>` | :ref:`get_h_scrollbar<class_ScrollContainer_method_get_h_scrollbar>` **(** **)** |
  49. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`VScrollBar<class_VScrollBar>` | :ref:`get_v_scrollbar<class_ScrollContainer_method_get_v_scrollbar>` **(** **)** |
  51. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  52. .. rst-class:: classref-reftable-group
  53. Theme Properties
  54. ----------------
  55. .. table::
  56. :widths: auto
  57. +---------------------------------+-------------------------------------------------+
  58. | :ref:`StyleBox<class_StyleBox>` | :ref:`bg<class_ScrollContainer_theme_style_bg>` |
  59. +---------------------------------+-------------------------------------------------+
  60. .. rst-class:: classref-section-separator
  61. ----
  62. .. rst-class:: classref-descriptions-group
  63. Signals
  64. -------
  65. .. _class_ScrollContainer_signal_scroll_ended:
  66. .. rst-class:: classref-signal
  67. **scroll_ended** **(** **)**
  68. Emitted when scrolling stops.
  69. .. rst-class:: classref-item-separator
  70. ----
  71. .. _class_ScrollContainer_signal_scroll_started:
  72. .. rst-class:: classref-signal
  73. **scroll_started** **(** **)**
  74. Emitted when scrolling is started.
  75. .. rst-class:: classref-section-separator
  76. ----
  77. .. rst-class:: classref-descriptions-group
  78. Property Descriptions
  79. ---------------------
  80. .. _class_ScrollContainer_property_follow_focus:
  81. .. rst-class:: classref-property
  82. :ref:`bool<class_bool>` **follow_focus** = ``false``
  83. .. rst-class:: classref-property-setget
  84. - void **set_follow_focus** **(** :ref:`bool<class_bool>` value **)**
  85. - :ref:`bool<class_bool>` **is_following_focus** **(** **)**
  86. If ``true``, the ScrollContainer will automatically scroll to focused children (including indirect children) to make sure they are fully visible.
  87. .. rst-class:: classref-item-separator
  88. ----
  89. .. _class_ScrollContainer_property_scroll_deadzone:
  90. .. rst-class:: classref-property
  91. :ref:`int<class_int>` **scroll_deadzone** = ``0``
  92. .. rst-class:: classref-property-setget
  93. - void **set_deadzone** **(** :ref:`int<class_int>` value **)**
  94. - :ref:`int<class_int>` **get_deadzone** **(** **)**
  95. .. container:: contribute
  96. There is currently no description for this property. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  97. .. rst-class:: classref-item-separator
  98. ----
  99. .. _class_ScrollContainer_property_scroll_horizontal:
  100. .. rst-class:: classref-property
  101. :ref:`int<class_int>` **scroll_horizontal** = ``0``
  102. .. rst-class:: classref-property-setget
  103. - void **set_h_scroll** **(** :ref:`int<class_int>` value **)**
  104. - :ref:`int<class_int>` **get_h_scroll** **(** **)**
  105. The current horizontal scroll value.
  106. \ **Note:** If you are setting this value in the :ref:`Node._ready<class_Node_method__ready>` function or earlier, it needs to be wrapped with :ref:`Object.set_deferred<class_Object_method_set_deferred>`, since scroll bar's :ref:`Range.max_value<class_Range_property_max_value>` is not initialized yet.
  107. ::
  108. func _ready():
  109. set_deferred("scroll_horizontal", 600)
  110. .. rst-class:: classref-item-separator
  111. ----
  112. .. _class_ScrollContainer_property_scroll_horizontal_enabled:
  113. .. rst-class:: classref-property
  114. :ref:`bool<class_bool>` **scroll_horizontal_enabled** = ``true``
  115. .. rst-class:: classref-property-setget
  116. - void **set_enable_h_scroll** **(** :ref:`bool<class_bool>` value **)**
  117. - :ref:`bool<class_bool>` **is_h_scroll_enabled** **(** **)**
  118. If ``true``, enables horizontal scrolling.
  119. .. rst-class:: classref-item-separator
  120. ----
  121. .. _class_ScrollContainer_property_scroll_vertical:
  122. .. rst-class:: classref-property
  123. :ref:`int<class_int>` **scroll_vertical** = ``0``
  124. .. rst-class:: classref-property-setget
  125. - void **set_v_scroll** **(** :ref:`int<class_int>` value **)**
  126. - :ref:`int<class_int>` **get_v_scroll** **(** **)**
  127. The current vertical scroll value.
  128. \ **Note:** Setting it early needs to be deferred, just like in :ref:`scroll_horizontal<class_ScrollContainer_property_scroll_horizontal>`.
  129. ::
  130. func _ready():
  131. set_deferred("scroll_vertical", 600)
  132. .. rst-class:: classref-item-separator
  133. ----
  134. .. _class_ScrollContainer_property_scroll_vertical_enabled:
  135. .. rst-class:: classref-property
  136. :ref:`bool<class_bool>` **scroll_vertical_enabled** = ``true``
  137. .. rst-class:: classref-property-setget
  138. - void **set_enable_v_scroll** **(** :ref:`bool<class_bool>` value **)**
  139. - :ref:`bool<class_bool>` **is_v_scroll_enabled** **(** **)**
  140. If ``true``, enables vertical scrolling.
  141. .. rst-class:: classref-section-separator
  142. ----
  143. .. rst-class:: classref-descriptions-group
  144. Method Descriptions
  145. -------------------
  146. .. _class_ScrollContainer_method_ensure_control_visible:
  147. .. rst-class:: classref-method
  148. void **ensure_control_visible** **(** :ref:`Control<class_Control>` control **)**
  149. 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>`.
  150. \ **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.idle_frame<class_SceneTree_signal_idle_frame>`:
  151. ::
  152. add_child(child_node)
  153. yield(get_tree(), "idle_frame")
  154. ensure_control_visible(child_node)
  155. .. rst-class:: classref-item-separator
  156. ----
  157. .. _class_ScrollContainer_method_get_h_scrollbar:
  158. .. rst-class:: classref-method
  159. :ref:`HScrollBar<class_HScrollBar>` **get_h_scrollbar** **(** **)**
  160. Returns the horizontal scrollbar :ref:`HScrollBar<class_HScrollBar>` of this **ScrollContainer**.
  161. \ **Warning:** This is a required internal node, removing and freeing it may cause a crash. If you wish to disable the horizontal scrollbar, use :ref:`scroll_horizontal_enabled<class_ScrollContainer_property_scroll_horizontal_enabled>`. If you want to only hide it instead, use its :ref:`CanvasItem.visible<class_CanvasItem_property_visible>` property.
  162. .. rst-class:: classref-item-separator
  163. ----
  164. .. _class_ScrollContainer_method_get_v_scrollbar:
  165. .. rst-class:: classref-method
  166. :ref:`VScrollBar<class_VScrollBar>` **get_v_scrollbar** **(** **)**
  167. Returns the vertical scrollbar :ref:`VScrollBar<class_VScrollBar>` of this **ScrollContainer**.
  168. \ **Warning:** This is a required internal node, removing and freeing it may cause a crash. If you wish to disable the vertical scrollbar, use :ref:`scroll_vertical_enabled<class_ScrollContainer_property_scroll_vertical_enabled>`. If you want to only hide it instead, use its :ref:`CanvasItem.visible<class_CanvasItem_property_visible>` property.
  169. .. rst-class:: classref-section-separator
  170. ----
  171. .. rst-class:: classref-descriptions-group
  172. Theme Property Descriptions
  173. ---------------------------
  174. .. _class_ScrollContainer_theme_style_bg:
  175. .. rst-class:: classref-themeproperty
  176. :ref:`StyleBox<class_StyleBox>` **bg**
  177. The background :ref:`StyleBox<class_StyleBox>` of the **ScrollContainer**.
  178. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  179. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  180. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  181. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`