class_spinbox.rst 8.0 KB

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