class_label.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Label.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Label:
  5. Label
  6. =====
  7. **Inherits:** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Displays plain text in a line or wrapped inside a rectangle. For formatted text, use :ref:`RichTextLabel<class_RichTextLabel>`.
  12. Properties
  13. ----------
  14. +----------------------------------+--------------------------------------------------------------------+
  15. | :ref:`Align<enum_Label_Align>` | :ref:`align<class_Label_property_align>` |
  16. +----------------------------------+--------------------------------------------------------------------+
  17. | :ref:`bool<class_bool>` | :ref:`autowrap<class_Label_property_autowrap>` |
  18. +----------------------------------+--------------------------------------------------------------------+
  19. | :ref:`bool<class_bool>` | :ref:`clip_text<class_Label_property_clip_text>` |
  20. +----------------------------------+--------------------------------------------------------------------+
  21. | :ref:`int<class_int>` | :ref:`lines_skipped<class_Label_property_lines_skipped>` |
  22. +----------------------------------+--------------------------------------------------------------------+
  23. | :ref:`int<class_int>` | :ref:`max_lines_visible<class_Label_property_max_lines_visible>` |
  24. +----------------------------------+--------------------------------------------------------------------+
  25. | :ref:`float<class_float>` | :ref:`percent_visible<class_Label_property_percent_visible>` |
  26. +----------------------------------+--------------------------------------------------------------------+
  27. | :ref:`String<class_String>` | :ref:`text<class_Label_property_text>` |
  28. +----------------------------------+--------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`uppercase<class_Label_property_uppercase>` |
  30. +----------------------------------+--------------------------------------------------------------------+
  31. | :ref:`VAlign<enum_Label_VAlign>` | :ref:`valign<class_Label_property_valign>` |
  32. +----------------------------------+--------------------------------------------------------------------+
  33. | :ref:`int<class_int>` | :ref:`visible_characters<class_Label_property_visible_characters>` |
  34. +----------------------------------+--------------------------------------------------------------------+
  35. Methods
  36. -------
  37. +-----------------------+--------------------------------------------------------------------------------------------------+
  38. | :ref:`int<class_int>` | :ref:`get_line_count<class_Label_method_get_line_count>` **(** **)** const |
  39. +-----------------------+--------------------------------------------------------------------------------------------------+
  40. | :ref:`int<class_int>` | :ref:`get_line_height<class_Label_method_get_line_height>` **(** **)** const |
  41. +-----------------------+--------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`get_total_character_count<class_Label_method_get_total_character_count>` **(** **)** const |
  43. +-----------------------+--------------------------------------------------------------------------------------------------+
  44. | :ref:`int<class_int>` | :ref:`get_visible_line_count<class_Label_method_get_visible_line_count>` **(** **)** const |
  45. +-----------------------+--------------------------------------------------------------------------------------------------+
  46. Theme Properties
  47. ----------------
  48. +---------------------------------+-----------------------+
  49. | :ref:`Font<class_Font>` | font |
  50. +---------------------------------+-----------------------+
  51. | :ref:`Color<class_Color>` | font_color |
  52. +---------------------------------+-----------------------+
  53. | :ref:`Color<class_Color>` | font_color_shadow |
  54. +---------------------------------+-----------------------+
  55. | :ref:`Color<class_Color>` | font_outline_modulate |
  56. +---------------------------------+-----------------------+
  57. | :ref:`int<class_int>` | line_spacing |
  58. +---------------------------------+-----------------------+
  59. | :ref:`StyleBox<class_StyleBox>` | normal |
  60. +---------------------------------+-----------------------+
  61. | :ref:`int<class_int>` | shadow_as_outline |
  62. +---------------------------------+-----------------------+
  63. | :ref:`int<class_int>` | shadow_offset_x |
  64. +---------------------------------+-----------------------+
  65. | :ref:`int<class_int>` | shadow_offset_y |
  66. +---------------------------------+-----------------------+
  67. Enumerations
  68. ------------
  69. .. _enum_Label_Align:
  70. .. _class_Label_constant_ALIGN_LEFT:
  71. .. _class_Label_constant_ALIGN_CENTER:
  72. .. _class_Label_constant_ALIGN_RIGHT:
  73. .. _class_Label_constant_ALIGN_FILL:
  74. enum **Align**:
  75. - **ALIGN_LEFT** = **0** --- Align rows to the left (default).
  76. - **ALIGN_CENTER** = **1** --- Align rows centered.
  77. - **ALIGN_RIGHT** = **2** --- Align rows to the right (default).
  78. - **ALIGN_FILL** = **3** --- Expand row whitespaces to fit the width.
  79. .. _enum_Label_VAlign:
  80. .. _class_Label_constant_VALIGN_TOP:
  81. .. _class_Label_constant_VALIGN_CENTER:
  82. .. _class_Label_constant_VALIGN_BOTTOM:
  83. .. _class_Label_constant_VALIGN_FILL:
  84. enum **VAlign**:
  85. - **VALIGN_TOP** = **0** --- Align the whole text to the top.
  86. - **VALIGN_CENTER** = **1** --- Align the whole text to the center.
  87. - **VALIGN_BOTTOM** = **2** --- Align the whole text to the bottom.
  88. - **VALIGN_FILL** = **3** --- Align the whole text by spreading the rows.
  89. Description
  90. -----------
  91. Label displays plain text on the screen. It gives you control over the horizontal and vertical alignment, and can wrap the text inside the node's bounding rectangle. It doesn't support bold, italics or other formatting. For that, use :ref:`RichTextLabel<class_RichTextLabel>` instead.
  92. Note that contrarily to most other :ref:`Control<class_Control>`\ s, Label's :ref:`Control.mouse_filter<class_Control_property_mouse_filter>` defaults to MOUSE_FILTER_IGNORE (i.e. it doesn't react to mouse input events).
  93. Property Descriptions
  94. ---------------------
  95. .. _class_Label_property_align:
  96. - :ref:`Align<enum_Label_Align>` **align**
  97. +----------+------------------+
  98. | *Setter* | set_align(value) |
  99. +----------+------------------+
  100. | *Getter* | get_align() |
  101. +----------+------------------+
  102. Controls the text's horizontal align. Supports left, center, right, and fill, or justify. Set it to one of the ``ALIGN_*`` constants.
  103. .. _class_Label_property_autowrap:
  104. - :ref:`bool<class_bool>` **autowrap**
  105. +----------+---------------------+
  106. | *Setter* | set_autowrap(value) |
  107. +----------+---------------------+
  108. | *Getter* | has_autowrap() |
  109. +----------+---------------------+
  110. If ``true``, wraps the text inside the node's bounding rectangle. If you resize the node, it will change its height automatically to show all the text. Default: false.
  111. .. _class_Label_property_clip_text:
  112. - :ref:`bool<class_bool>` **clip_text**
  113. +----------+----------------------+
  114. | *Setter* | set_clip_text(value) |
  115. +----------+----------------------+
  116. | *Getter* | is_clipping_text() |
  117. +----------+----------------------+
  118. If ``true``, the Label only shows the text that fits inside its bounding rectangle. It also lets you scale the node down freely.
  119. .. _class_Label_property_lines_skipped:
  120. - :ref:`int<class_int>` **lines_skipped**
  121. +----------+--------------------------+
  122. | *Setter* | set_lines_skipped(value) |
  123. +----------+--------------------------+
  124. | *Getter* | get_lines_skipped() |
  125. +----------+--------------------------+
  126. The node ignores the first ``lines_skipped`` lines before it starts to display text.
  127. .. _class_Label_property_max_lines_visible:
  128. - :ref:`int<class_int>` **max_lines_visible**
  129. +----------+------------------------------+
  130. | *Setter* | set_max_lines_visible(value) |
  131. +----------+------------------------------+
  132. | *Getter* | get_max_lines_visible() |
  133. +----------+------------------------------+
  134. Limits the lines of text the node shows on screen.
  135. .. _class_Label_property_percent_visible:
  136. - :ref:`float<class_float>` **percent_visible**
  137. +----------+----------------------------+
  138. | *Setter* | set_percent_visible(value) |
  139. +----------+----------------------------+
  140. | *Getter* | get_percent_visible() |
  141. +----------+----------------------------+
  142. Limits the count of visible characters. If you set ``percent_visible`` to 50, only up to half of the text's characters will display on screen. Useful to animate the text in a dialog box.
  143. .. _class_Label_property_text:
  144. - :ref:`String<class_String>` **text**
  145. +----------+-----------------+
  146. | *Setter* | set_text(value) |
  147. +----------+-----------------+
  148. | *Getter* | get_text() |
  149. +----------+-----------------+
  150. The text to display on screen.
  151. .. _class_Label_property_uppercase:
  152. - :ref:`bool<class_bool>` **uppercase**
  153. +----------+----------------------+
  154. | *Setter* | set_uppercase(value) |
  155. +----------+----------------------+
  156. | *Getter* | is_uppercase() |
  157. +----------+----------------------+
  158. If ``true``, all the text displays as UPPERCASE.
  159. .. _class_Label_property_valign:
  160. - :ref:`VAlign<enum_Label_VAlign>` **valign**
  161. +----------+-------------------+
  162. | *Setter* | set_valign(value) |
  163. +----------+-------------------+
  164. | *Getter* | get_valign() |
  165. +----------+-------------------+
  166. Controls the text's vertical align. Supports top, center, bottom, and fill. Set it to one of the ``VALIGN_*`` constants.
  167. .. _class_Label_property_visible_characters:
  168. - :ref:`int<class_int>` **visible_characters**
  169. +----------+-------------------------------+
  170. | *Setter* | set_visible_characters(value) |
  171. +----------+-------------------------------+
  172. | *Getter* | get_visible_characters() |
  173. +----------+-------------------------------+
  174. Restricts the number of characters to display. Set to -1 to disable.
  175. Method Descriptions
  176. -------------------
  177. .. _class_Label_method_get_line_count:
  178. - :ref:`int<class_int>` **get_line_count** **(** **)** const
  179. Returns the amount of lines of text the Label has.
  180. .. _class_Label_method_get_line_height:
  181. - :ref:`int<class_int>` **get_line_height** **(** **)** const
  182. Returns the font size in pixels.
  183. .. _class_Label_method_get_total_character_count:
  184. - :ref:`int<class_int>` **get_total_character_count** **(** **)** const
  185. Returns the total number of printable characters in the text (excluding spaces and newlines).
  186. .. _class_Label_method_get_visible_line_count:
  187. - :ref:`int<class_int>` **get_visible_line_count** **(** **)** const
  188. Returns the number of lines shown. Useful if the ``Label`` 's height cannot currently display all lines.