class_label.rst 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. Member Functions
  13. ----------------
  14. +------------------------+-------------------------------------------------------------------------------------------+
  15. | :ref:`int<class_int>` | :ref:`get_line_count<class_Label_get_line_count>` **(** **)** const |
  16. +------------------------+-------------------------------------------------------------------------------------------+
  17. | :ref:`int<class_int>` | :ref:`get_line_height<class_Label_get_line_height>` **(** **)** const |
  18. +------------------------+-------------------------------------------------------------------------------------------+
  19. | :ref:`int<class_int>` | :ref:`get_total_character_count<class_Label_get_total_character_count>` **(** **)** const |
  20. +------------------------+-------------------------------------------------------------------------------------------+
  21. | :ref:`int<class_int>` | :ref:`get_visible_line_count<class_Label_get_visible_line_count>` **(** **)** const |
  22. +------------------------+-------------------------------------------------------------------------------------------+
  23. Member Variables
  24. ----------------
  25. .. _class_Label_align:
  26. - :ref:`Align<enum_label_align>` **align** - Controls the text's horizontal align. Supports left, center, right, and fill, or justify. Set it to one of the ``ALIGN_*`` constants.
  27. .. _class_Label_autowrap:
  28. - :ref:`bool<class_bool>` **autowrap** - 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.
  29. .. _class_Label_clip_text:
  30. - :ref:`bool<class_bool>` **clip_text** - If ``true``, the Label only shows the text that fits inside its bounding rectangle. It also lets you scale the node down freely.
  31. .. _class_Label_lines_skipped:
  32. - :ref:`int<class_int>` **lines_skipped** - The node ignores the first ``lines_skipped`` lines before it starts to display text.
  33. .. _class_Label_max_lines_visible:
  34. - :ref:`int<class_int>` **max_lines_visible** - Limits the lines of text the node shows on screen.
  35. .. _class_Label_percent_visible:
  36. - :ref:`float<class_float>` **percent_visible** - 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.
  37. .. _class_Label_text:
  38. - :ref:`String<class_string>` **text** - The text to display on screen.
  39. .. _class_Label_uppercase:
  40. - :ref:`bool<class_bool>` **uppercase** - If ``true``, all the text displays as UPPERCASE.
  41. .. _class_Label_valign:
  42. - :ref:`VAlign<enum_label_valign>` **valign** - Controls the text's vertical align. Supports top, center, bottom, and fill. Set it to one of the ``VALIGN_*`` constants.
  43. .. _class_Label_visible_characters:
  44. - :ref:`int<class_int>` **visible_characters** - Restricts the number of characters to display. Set to -1 to disable.
  45. Enums
  46. -----
  47. .. _enum_Label_Align:
  48. enum **Align**
  49. - **ALIGN_LEFT** = **0** --- Align rows to the left (default).
  50. - **ALIGN_CENTER** = **1** --- Align rows centered.
  51. - **ALIGN_RIGHT** = **2** --- Align rows to the right (default).
  52. - **ALIGN_FILL** = **3** --- Expand row whitespaces to fit the width.
  53. .. _enum_Label_VAlign:
  54. enum **VAlign**
  55. - **VALIGN_TOP** = **0** --- Align the whole text to the top.
  56. - **VALIGN_CENTER** = **1** --- Align the whole text to the center.
  57. - **VALIGN_BOTTOM** = **2** --- Align the whole text to the bottom.
  58. - **VALIGN_FILL** = **3** --- Align the whole text by spreading the rows.
  59. Description
  60. -----------
  61. 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.
  62. Note that contrarily to most other :ref:`Control<class_control>`\ s, Label's :ref:`Control.mouse_filter<class_Control_mouse_filter>` defaults to MOUSE_FILTER_IGNORE (i.e. it doesn't react to mouse input events).
  63. Member Function Description
  64. ---------------------------
  65. .. _class_Label_get_line_count:
  66. - :ref:`int<class_int>` **get_line_count** **(** **)** const
  67. Returns the amount of lines of text the Label has.
  68. .. _class_Label_get_line_height:
  69. - :ref:`int<class_int>` **get_line_height** **(** **)** const
  70. Returns the font size in pixels.
  71. .. _class_Label_get_total_character_count:
  72. - :ref:`int<class_int>` **get_total_character_count** **(** **)** const
  73. Returns the total length of the text.
  74. .. _class_Label_get_visible_line_count:
  75. - :ref:`int<class_int>` **get_visible_line_count** **(** **)** const
  76. Returns the number of lines shown. Useful if the ``Label`` 's height cannot currently display all lines.