virtualx-engine-docs/_sources/classes/class_label.rst.txt
2024-10-23 09:41:33 -07:00

548 lines
21 KiB
ReStructuredText

:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/Label.xml.
.. _class_Label:
Label
=====
**Inherits:** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
Displays plain text in a line or wrapped inside a rectangle. For formatted text, use :ref:`RichTextLabel<class_RichTextLabel>`.
.. rst-class:: classref-introduction-group
Description
-----------
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.
\ **Note:** Contrarily to most other :ref:`Control<class_Control>`\ s, Label's :ref:`Control.mouse_filter<class_Control_property_mouse_filter>` defaults to :ref:`Control.MOUSE_FILTER_IGNORE<class_Control_constant_MOUSE_FILTER_IGNORE>` (i.e. it doesn't react to mouse input events). This implies that a label won't display any configured :ref:`Control.hint_tooltip<class_Control_property_hint_tooltip>`, unless you change its mouse filter.
\ **Note:** Unicode characters after ``0xffff`` (such as most emoji) are *not* supported on Windows. They will display as unknown characters instead. This will be resolved in Godot 4.0.
.. rst-class:: classref-introduction-group
Tutorials
---------
- `2D Dodge The Creeps Demo <https://godotengine.org/asset-library/asset/515>`__
.. rst-class:: classref-reftable-group
Properties
----------
.. table::
:widths: auto
+----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+
| :ref:`Align<enum_Label_Align>` | :ref:`align<class_Label_property_align>` | ``0`` |
+----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`autowrap<class_Label_property_autowrap>` | ``false`` |
+----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`clip_text<class_Label_property_clip_text>` | ``false`` |
+----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`lines_skipped<class_Label_property_lines_skipped>` | ``0`` |
+----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`max_lines_visible<class_Label_property_max_lines_visible>` | ``-1`` |
+----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+
| :ref:`MouseFilter<enum_Control_MouseFilter>` | mouse_filter | ``2`` (overrides :ref:`Control<class_Control_property_mouse_filter>`) |
+----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`percent_visible<class_Label_property_percent_visible>` | ``1.0`` |
+----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+
| :ref:`int<class_int>` | size_flags_vertical | ``4`` (overrides :ref:`Control<class_Control_property_size_flags_vertical>`) |
+----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`text<class_Label_property_text>` | ``""`` |
+----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`uppercase<class_Label_property_uppercase>` | ``false`` |
+----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+
| :ref:`VAlign<enum_Label_VAlign>` | :ref:`valign<class_Label_property_valign>` | ``0`` |
+----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`visible_characters<class_Label_property_visible_characters>` | ``-1`` |
+----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+
.. rst-class:: classref-reftable-group
Methods
-------
.. table::
:widths: auto
+-----------------------+----------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_line_count<class_Label_method_get_line_count>` **(** **)** |const| |
+-----------------------+----------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_line_height<class_Label_method_get_line_height>` **(** **)** |const| |
+-----------------------+----------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_total_character_count<class_Label_method_get_total_character_count>` **(** **)** |const| |
+-----------------------+----------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_visible_line_count<class_Label_method_get_visible_line_count>` **(** **)** |const| |
+-----------------------+----------------------------------------------------------------------------------------------------+
.. rst-class:: classref-reftable-group
Theme Properties
----------------
.. table::
:widths: auto
+---------------------------------+-----------------------------------------------------------------------------+-------------------------+
| :ref:`Color<class_Color>` | :ref:`font_color<class_Label_theme_color_font_color>` | ``Color( 1, 1, 1, 1 )`` |
+---------------------------------+-----------------------------------------------------------------------------+-------------------------+
| :ref:`Color<class_Color>` | :ref:`font_color_shadow<class_Label_theme_color_font_color_shadow>` | ``Color( 0, 0, 0, 0 )`` |
+---------------------------------+-----------------------------------------------------------------------------+-------------------------+
| :ref:`Color<class_Color>` | :ref:`font_outline_modulate<class_Label_theme_color_font_outline_modulate>` | ``Color( 1, 1, 1, 1 )`` |
+---------------------------------+-----------------------------------------------------------------------------+-------------------------+
| :ref:`int<class_int>` | :ref:`line_spacing<class_Label_theme_constant_line_spacing>` | ``3`` |
+---------------------------------+-----------------------------------------------------------------------------+-------------------------+
| :ref:`int<class_int>` | :ref:`shadow_as_outline<class_Label_theme_constant_shadow_as_outline>` | ``0`` |
+---------------------------------+-----------------------------------------------------------------------------+-------------------------+
| :ref:`int<class_int>` | :ref:`shadow_offset_x<class_Label_theme_constant_shadow_offset_x>` | ``1`` |
+---------------------------------+-----------------------------------------------------------------------------+-------------------------+
| :ref:`int<class_int>` | :ref:`shadow_offset_y<class_Label_theme_constant_shadow_offset_y>` | ``1`` |
+---------------------------------+-----------------------------------------------------------------------------+-------------------------+
| :ref:`Font<class_Font>` | :ref:`font<class_Label_theme_font_font>` | |
+---------------------------------+-----------------------------------------------------------------------------+-------------------------+
| :ref:`StyleBox<class_StyleBox>` | :ref:`normal<class_Label_theme_style_normal>` | |
+---------------------------------+-----------------------------------------------------------------------------+-------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Enumerations
------------
.. _enum_Label_Align:
.. rst-class:: classref-enumeration
enum **Align**:
.. _class_Label_constant_ALIGN_LEFT:
.. rst-class:: classref-enumeration-constant
:ref:`Align<enum_Label_Align>` **ALIGN_LEFT** = ``0``
Align rows to the left (default).
.. _class_Label_constant_ALIGN_CENTER:
.. rst-class:: classref-enumeration-constant
:ref:`Align<enum_Label_Align>` **ALIGN_CENTER** = ``1``
Align rows centered.
.. _class_Label_constant_ALIGN_RIGHT:
.. rst-class:: classref-enumeration-constant
:ref:`Align<enum_Label_Align>` **ALIGN_RIGHT** = ``2``
Align rows to the right.
.. _class_Label_constant_ALIGN_FILL:
.. rst-class:: classref-enumeration-constant
:ref:`Align<enum_Label_Align>` **ALIGN_FILL** = ``3``
Expand row whitespaces to fit the width.
.. rst-class:: classref-item-separator
----
.. _enum_Label_VAlign:
.. rst-class:: classref-enumeration
enum **VAlign**:
.. _class_Label_constant_VALIGN_TOP:
.. rst-class:: classref-enumeration-constant
:ref:`VAlign<enum_Label_VAlign>` **VALIGN_TOP** = ``0``
Align the whole text to the top.
.. _class_Label_constant_VALIGN_CENTER:
.. rst-class:: classref-enumeration-constant
:ref:`VAlign<enum_Label_VAlign>` **VALIGN_CENTER** = ``1``
Align the whole text to the center.
.. _class_Label_constant_VALIGN_BOTTOM:
.. rst-class:: classref-enumeration-constant
:ref:`VAlign<enum_Label_VAlign>` **VALIGN_BOTTOM** = ``2``
Align the whole text to the bottom.
.. _class_Label_constant_VALIGN_FILL:
.. rst-class:: classref-enumeration-constant
:ref:`VAlign<enum_Label_VAlign>` **VALIGN_FILL** = ``3``
Align the whole text by spreading the rows.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Property Descriptions
---------------------
.. _class_Label_property_align:
.. rst-class:: classref-property
:ref:`Align<enum_Label_Align>` **align** = ``0``
.. rst-class:: classref-property-setget
- void **set_align** **(** :ref:`Align<enum_Label_Align>` value **)**
- :ref:`Align<enum_Label_Align>` **get_align** **(** **)**
Controls the text's horizontal align. Supports left, center, right, and fill, or justify. Set it to one of the :ref:`Align<enum_Label_Align>` constants.
.. rst-class:: classref-item-separator
----
.. _class_Label_property_autowrap:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **autowrap** = ``false``
.. rst-class:: classref-property-setget
- void **set_autowrap** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **has_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.
.. rst-class:: classref-item-separator
----
.. _class_Label_property_clip_text:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **clip_text** = ``false``
.. rst-class:: classref-property-setget
- void **set_clip_text** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **is_clipping_text** **(** **)**
If ``true``, the Label only shows the text that fits inside its bounding rectangle and will clip text horizontally.
.. rst-class:: classref-item-separator
----
.. _class_Label_property_lines_skipped:
.. rst-class:: classref-property
:ref:`int<class_int>` **lines_skipped** = ``0``
.. rst-class:: classref-property-setget
- void **set_lines_skipped** **(** :ref:`int<class_int>` value **)**
- :ref:`int<class_int>` **get_lines_skipped** **(** **)**
The node ignores the first ``lines_skipped`` lines before it starts to display text.
.. rst-class:: classref-item-separator
----
.. _class_Label_property_max_lines_visible:
.. rst-class:: classref-property
:ref:`int<class_int>` **max_lines_visible** = ``-1``
.. rst-class:: classref-property-setget
- void **set_max_lines_visible** **(** :ref:`int<class_int>` value **)**
- :ref:`int<class_int>` **get_max_lines_visible** **(** **)**
Limits the lines of text the node shows on screen.
.. rst-class:: classref-item-separator
----
.. _class_Label_property_percent_visible:
.. rst-class:: classref-property
:ref:`float<class_float>` **percent_visible** = ``1.0``
.. rst-class:: classref-property-setget
- void **set_percent_visible** **(** :ref:`float<class_float>` value **)**
- :ref:`float<class_float>` **get_percent_visible** **(** **)**
Limits the amount of visible characters. If you set ``percent_visible`` to 0.5, only up to half of the text's characters will display on screen. Useful to animate the text in a dialog box.
.. rst-class:: classref-item-separator
----
.. _class_Label_property_text:
.. rst-class:: classref-property
:ref:`String<class_String>` **text** = ``""``
.. rst-class:: classref-property-setget
- void **set_text** **(** :ref:`String<class_String>` value **)**
- :ref:`String<class_String>` **get_text** **(** **)**
The text to display on screen.
.. rst-class:: classref-item-separator
----
.. _class_Label_property_uppercase:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **uppercase** = ``false``
.. rst-class:: classref-property-setget
- void **set_uppercase** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **is_uppercase** **(** **)**
If ``true``, all the text displays as UPPERCASE.
.. rst-class:: classref-item-separator
----
.. _class_Label_property_valign:
.. rst-class:: classref-property
:ref:`VAlign<enum_Label_VAlign>` **valign** = ``0``
.. rst-class:: classref-property-setget
- void **set_valign** **(** :ref:`VAlign<enum_Label_VAlign>` value **)**
- :ref:`VAlign<enum_Label_VAlign>` **get_valign** **(** **)**
Controls the text's vertical align. Supports top, center, bottom, and fill. Set it to one of the :ref:`VAlign<enum_Label_VAlign>` constants.
.. rst-class:: classref-item-separator
----
.. _class_Label_property_visible_characters:
.. rst-class:: classref-property
:ref:`int<class_int>` **visible_characters** = ``-1``
.. rst-class:: classref-property-setget
- void **set_visible_characters** **(** :ref:`int<class_int>` value **)**
- :ref:`int<class_int>` **get_visible_characters** **(** **)**
Restricts the number of characters to display. Set to -1 to disable.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Method Descriptions
-------------------
.. _class_Label_method_get_line_count:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_line_count** **(** **)** |const|
Returns the amount of lines of text the Label has.
.. rst-class:: classref-item-separator
----
.. _class_Label_method_get_line_height:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_line_height** **(** **)** |const|
Returns the font size in pixels.
.. rst-class:: classref-item-separator
----
.. _class_Label_method_get_total_character_count:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_total_character_count** **(** **)** |const|
Returns the total number of printable characters in the text (excluding spaces and newlines).
.. rst-class:: classref-item-separator
----
.. _class_Label_method_get_visible_line_count:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_visible_line_count** **(** **)** |const|
Returns the number of lines shown. Useful if the **Label**'s height cannot currently display all lines.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Theme Property Descriptions
---------------------------
.. _class_Label_theme_color_font_color:
.. rst-class:: classref-themeproperty
:ref:`Color<class_Color>` **font_color** = ``Color( 1, 1, 1, 1 )``
Default text :ref:`Color<class_Color>` of the **Label**.
.. rst-class:: classref-item-separator
----
.. _class_Label_theme_color_font_color_shadow:
.. rst-class:: classref-themeproperty
:ref:`Color<class_Color>` **font_color_shadow** = ``Color( 0, 0, 0, 0 )``
:ref:`Color<class_Color>` of the text's shadow effect.
.. rst-class:: classref-item-separator
----
.. _class_Label_theme_color_font_outline_modulate:
.. rst-class:: classref-themeproperty
:ref:`Color<class_Color>` **font_outline_modulate** = ``Color( 1, 1, 1, 1 )``
The tint of :ref:`Font<class_Font>`'s outline. See :ref:`DynamicFont.outline_color<class_DynamicFont_property_outline_color>`.
.. rst-class:: classref-item-separator
----
.. _class_Label_theme_constant_line_spacing:
.. rst-class:: classref-themeproperty
:ref:`int<class_int>` **line_spacing** = ``3``
Vertical space between lines in multiline **Label**.
.. rst-class:: classref-item-separator
----
.. _class_Label_theme_constant_shadow_as_outline:
.. rst-class:: classref-themeproperty
:ref:`int<class_int>` **shadow_as_outline** = ``0``
Boolean value. If set to 1 (``true``), the shadow will be displayed around the whole text as an outline.
.. rst-class:: classref-item-separator
----
.. _class_Label_theme_constant_shadow_offset_x:
.. rst-class:: classref-themeproperty
:ref:`int<class_int>` **shadow_offset_x** = ``1``
The horizontal offset of the text's shadow.
.. rst-class:: classref-item-separator
----
.. _class_Label_theme_constant_shadow_offset_y:
.. rst-class:: classref-themeproperty
:ref:`int<class_int>` **shadow_offset_y** = ``1``
The vertical offset of the text's shadow.
.. rst-class:: classref-item-separator
----
.. _class_Label_theme_font_font:
.. rst-class:: classref-themeproperty
:ref:`Font<class_Font>` **font**
:ref:`Font<class_Font>` used for the **Label**'s text.
.. rst-class:: classref-item-separator
----
.. _class_Label_theme_style_normal:
.. rst-class:: classref-themeproperty
:ref:`StyleBox<class_StyleBox>` **normal**
Background :ref:`StyleBox<class_StyleBox>` for the **Label**.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`