class_spinbox.rst 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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/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. Description
  12. -----------
  13. SpinBox is a numerical input text field. It allows entering integers and floats.
  14. \ **Example:**\
  15. .. tabs::
  16. .. code-tab:: gdscript
  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.horizontal_alignment = LineEdit.HORIZONTAL_ALIGNMENT_RIGHT
  22. .. code-tab:: csharp
  23. var spinBox = new SpinBox();
  24. AddChild(spinBox);
  25. var lineEdit = spinBox.GetLineEdit();
  26. lineEdit.ContextMenuEnabled = false;
  27. spinBox.AlignHorizontal = LineEdit.HorizontalAlignEnum.Right;
  28. The above code will create a ``SpinBox``, disable context menu on it and set the text alignment to right.
  29. See :ref:`Range<class_Range>` class for more options over the ``SpinBox``.
  30. \ **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.
  31. \ **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>`.
  32. Properties
  33. ----------
  34. +-------------------------------------------------------------------+------------------------------------------------------------------------------+-----------+
  35. | :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` | :ref:`alignment<class_SpinBox_property_alignment>` | ``0`` |
  36. +-------------------------------------------------------------------+------------------------------------------------------------------------------+-----------+
  37. | :ref:`bool<class_bool>` | :ref:`editable<class_SpinBox_property_editable>` | ``true`` |
  38. +-------------------------------------------------------------------+------------------------------------------------------------------------------+-----------+
  39. | :ref:`String<class_String>` | :ref:`prefix<class_SpinBox_property_prefix>` | ``""`` |
  40. +-------------------------------------------------------------------+------------------------------------------------------------------------------+-----------+
  41. | :ref:`String<class_String>` | :ref:`suffix<class_SpinBox_property_suffix>` | ``""`` |
  42. +-------------------------------------------------------------------+------------------------------------------------------------------------------+-----------+
  43. | :ref:`bool<class_bool>` | :ref:`update_on_text_changed<class_SpinBox_property_update_on_text_changed>` | ``false`` |
  44. +-------------------------------------------------------------------+------------------------------------------------------------------------------+-----------+
  45. Methods
  46. -------
  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. Theme Properties
  53. ----------------
  54. +-----------------------------------+------------------------------------------------+
  55. | :ref:`Texture2D<class_Texture2D>` | :ref:`updown<class_SpinBox_theme_icon_updown>` |
  56. +-----------------------------------+------------------------------------------------+
  57. Property Descriptions
  58. ---------------------
  59. .. _class_SpinBox_property_alignment:
  60. - :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` **alignment**
  61. +-----------+---------------------------------+
  62. | *Default* | ``0`` |
  63. +-----------+---------------------------------+
  64. | *Setter* | set_horizontal_alignment(value) |
  65. +-----------+---------------------------------+
  66. | *Getter* | get_horizontal_alignment() |
  67. +-----------+---------------------------------+
  68. ----
  69. .. _class_SpinBox_property_editable:
  70. - :ref:`bool<class_bool>` **editable**
  71. +-----------+---------------------+
  72. | *Default* | ``true`` |
  73. +-----------+---------------------+
  74. | *Setter* | set_editable(value) |
  75. +-----------+---------------------+
  76. | *Getter* | is_editable() |
  77. +-----------+---------------------+
  78. If ``true``, the ``SpinBox`` will be editable. Otherwise, it will be read only.
  79. ----
  80. .. _class_SpinBox_property_prefix:
  81. - :ref:`String<class_String>` **prefix**
  82. +-----------+-------------------+
  83. | *Default* | ``""`` |
  84. +-----------+-------------------+
  85. | *Setter* | set_prefix(value) |
  86. +-----------+-------------------+
  87. | *Getter* | get_prefix() |
  88. +-----------+-------------------+
  89. Adds the specified ``prefix`` string before the numerical value of the ``SpinBox``.
  90. ----
  91. .. _class_SpinBox_property_suffix:
  92. - :ref:`String<class_String>` **suffix**
  93. +-----------+-------------------+
  94. | *Default* | ``""`` |
  95. +-----------+-------------------+
  96. | *Setter* | set_suffix(value) |
  97. +-----------+-------------------+
  98. | *Getter* | get_suffix() |
  99. +-----------+-------------------+
  100. Adds the specified ``suffix`` string after the numerical value of the ``SpinBox``.
  101. ----
  102. .. _class_SpinBox_property_update_on_text_changed:
  103. - :ref:`bool<class_bool>` **update_on_text_changed**
  104. +-----------+-----------------------------------+
  105. | *Default* | ``false`` |
  106. +-----------+-----------------------------------+
  107. | *Setter* | set_update_on_text_changed(value) |
  108. +-----------+-----------------------------------+
  109. | *Getter* | get_update_on_text_changed() |
  110. +-----------+-----------------------------------+
  111. Sets the value of the :ref:`Range<class_Range>` for this ``SpinBox`` when the :ref:`LineEdit<class_LineEdit>` text is *changed* instead of *submitted*. See :ref:`LineEdit.text_changed<class_LineEdit_signal_text_changed>` and :ref:`LineEdit.text_submitted<class_LineEdit_signal_text_submitted>`.
  112. Method Descriptions
  113. -------------------
  114. .. _class_SpinBox_method_apply:
  115. - void **apply** **(** **)**
  116. Applies the current value of this ``SpinBox``.
  117. ----
  118. .. _class_SpinBox_method_get_line_edit:
  119. - :ref:`LineEdit<class_LineEdit>` **get_line_edit** **(** **)**
  120. Returns the :ref:`LineEdit<class_LineEdit>` instance from this ``SpinBox``. You can use it to access properties and methods of :ref:`LineEdit<class_LineEdit>`.
  121. \ **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.
  122. Theme Property Descriptions
  123. ---------------------------
  124. .. _class_SpinBox_theme_icon_updown:
  125. - :ref:`Texture2D<class_Texture2D>` **updown**
  126. Sets a custom :ref:`Texture2D<class_Texture2D>` for up and down arrows of the ``SpinBox``.
  127. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  128. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  129. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  130. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  131. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  132. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`