class_spinbox.rst 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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/SpinBox.xml.
  6. .. _class_SpinBox:
  7. SpinBox
  8. =======
  9. **Inherits:** :ref:`Range<class_Range>` **<** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Numerical input text field.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. SpinBox is a numerical input text field. It allows entering integers and floats.
  15. \ **Example:**\
  16. ::
  17. var spin_box = SpinBox.new()
  18. add_child(spin_box)
  19. var line_edit = spin_box.get_line_edit()
  20. line_edit.context_menu_enabled = false
  21. spin_box.align = LineEdit.ALIGN_RIGHT
  22. The above code will create a **SpinBox**, disable context menu on it and set the text alignment to right.
  23. See :ref:`Range<class_Range>` class for more options over the **SpinBox**.
  24. \ **Note:** **SpinBox** relies on an underlying :ref:`LineEdit<class_LineEdit>` node. To theme a **SpinBox**'s background, add theme items for :ref:`LineEdit<class_LineEdit>` and customize them.
  25. \ **Note:** If you want to implement drag and drop for the underlying :ref:`LineEdit<class_LineEdit>`, you can use :ref:`Control.set_drag_forwarding<class_Control_method_set_drag_forwarding>` on the node returned by :ref:`get_line_edit<class_SpinBox_method_get_line_edit>`.
  26. .. rst-class:: classref-reftable-group
  27. Properties
  28. ----------
  29. .. table::
  30. :widths: auto
  31. +-----------------------------------+--------------------------------------------------------------------+----------+
  32. | :ref:`Align<enum_LineEdit_Align>` | :ref:`align<class_SpinBox_property_align>` | ``0`` |
  33. +-----------------------------------+--------------------------------------------------------------------+----------+
  34. | :ref:`float<class_float>` | :ref:`custom_arrow_step<class_SpinBox_property_custom_arrow_step>` | ``0.0`` |
  35. +-----------------------------------+--------------------------------------------------------------------+----------+
  36. | :ref:`bool<class_bool>` | :ref:`editable<class_SpinBox_property_editable>` | ``true`` |
  37. +-----------------------------------+--------------------------------------------------------------------+----------+
  38. | :ref:`String<class_String>` | :ref:`prefix<class_SpinBox_property_prefix>` | ``""`` |
  39. +-----------------------------------+--------------------------------------------------------------------+----------+
  40. | :ref:`String<class_String>` | :ref:`suffix<class_SpinBox_property_suffix>` | ``""`` |
  41. +-----------------------------------+--------------------------------------------------------------------+----------+
  42. .. rst-class:: classref-reftable-group
  43. Methods
  44. -------
  45. .. table::
  46. :widths: auto
  47. +---------------------------------+----------------------------------------------------------------------+
  48. | void | :ref:`apply<class_SpinBox_method_apply>` **(** **)** |
  49. +---------------------------------+----------------------------------------------------------------------+
  50. | :ref:`LineEdit<class_LineEdit>` | :ref:`get_line_edit<class_SpinBox_method_get_line_edit>` **(** **)** |
  51. +---------------------------------+----------------------------------------------------------------------+
  52. .. rst-class:: classref-reftable-group
  53. Theme Properties
  54. ----------------
  55. .. table::
  56. :widths: auto
  57. +-------------------------------+------------------------------------------------+
  58. | :ref:`Texture<class_Texture>` | :ref:`updown<class_SpinBox_theme_icon_updown>` |
  59. +-------------------------------+------------------------------------------------+
  60. .. rst-class:: classref-section-separator
  61. ----
  62. .. rst-class:: classref-descriptions-group
  63. Property Descriptions
  64. ---------------------
  65. .. _class_SpinBox_property_align:
  66. .. rst-class:: classref-property
  67. :ref:`Align<enum_LineEdit_Align>` **align** = ``0``
  68. .. rst-class:: classref-property-setget
  69. - void **set_align** **(** :ref:`Align<enum_LineEdit_Align>` value **)**
  70. - :ref:`Align<enum_LineEdit_Align>` **get_align** **(** **)**
  71. Sets the text alignment of the **SpinBox**.
  72. .. rst-class:: classref-item-separator
  73. ----
  74. .. _class_SpinBox_property_custom_arrow_step:
  75. .. rst-class:: classref-property
  76. :ref:`float<class_float>` **custom_arrow_step** = ``0.0``
  77. .. rst-class:: classref-property-setget
  78. - void **set_custom_arrow_step** **(** :ref:`float<class_float>` value **)**
  79. - :ref:`float<class_float>` **get_custom_arrow_step** **(** **)**
  80. If not ``0``, ``value`` will always be rounded to a multiple of ``custom_arrow_step`` when interacting with the arrow buttons of the **SpinBox**.
  81. .. rst-class:: classref-item-separator
  82. ----
  83. .. _class_SpinBox_property_editable:
  84. .. rst-class:: classref-property
  85. :ref:`bool<class_bool>` **editable** = ``true``
  86. .. rst-class:: classref-property-setget
  87. - void **set_editable** **(** :ref:`bool<class_bool>` value **)**
  88. - :ref:`bool<class_bool>` **is_editable** **(** **)**
  89. If ``true``, the **SpinBox** will be editable. Otherwise, it will be read only.
  90. .. rst-class:: classref-item-separator
  91. ----
  92. .. _class_SpinBox_property_prefix:
  93. .. rst-class:: classref-property
  94. :ref:`String<class_String>` **prefix** = ``""``
  95. .. rst-class:: classref-property-setget
  96. - void **set_prefix** **(** :ref:`String<class_String>` value **)**
  97. - :ref:`String<class_String>` **get_prefix** **(** **)**
  98. Adds the specified ``prefix`` string before the numerical value of the **SpinBox**.
  99. .. rst-class:: classref-item-separator
  100. ----
  101. .. _class_SpinBox_property_suffix:
  102. .. rst-class:: classref-property
  103. :ref:`String<class_String>` **suffix** = ``""``
  104. .. rst-class:: classref-property-setget
  105. - void **set_suffix** **(** :ref:`String<class_String>` value **)**
  106. - :ref:`String<class_String>` **get_suffix** **(** **)**
  107. Adds the specified ``suffix`` string after the numerical value of the **SpinBox**.
  108. .. rst-class:: classref-section-separator
  109. ----
  110. .. rst-class:: classref-descriptions-group
  111. Method Descriptions
  112. -------------------
  113. .. _class_SpinBox_method_apply:
  114. .. rst-class:: classref-method
  115. void **apply** **(** **)**
  116. Applies the current value of this **SpinBox**.
  117. .. rst-class:: classref-item-separator
  118. ----
  119. .. _class_SpinBox_method_get_line_edit:
  120. .. rst-class:: classref-method
  121. :ref:`LineEdit<class_LineEdit>` **get_line_edit** **(** **)**
  122. Returns the :ref:`LineEdit<class_LineEdit>` instance from this **SpinBox**. You can use it to access properties and methods of :ref:`LineEdit<class_LineEdit>`.
  123. \ **Warning:** This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their :ref:`CanvasItem.visible<class_CanvasItem_property_visible>` property.
  124. .. rst-class:: classref-section-separator
  125. ----
  126. .. rst-class:: classref-descriptions-group
  127. Theme Property Descriptions
  128. ---------------------------
  129. .. _class_SpinBox_theme_icon_updown:
  130. .. rst-class:: classref-themeproperty
  131. :ref:`Texture<class_Texture>` **updown**
  132. Sets a custom :ref:`Texture<class_Texture>` for up and down arrows of the **SpinBox**.
  133. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  134. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  135. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  136. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`