Struct Label
Displays plain text in a line or wrapped inside a rectangle. For formatted text, use RichTextLabel
.
struct Label
;
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 RichTextLabel
instead.
Note: Contrarily to most other Control
s, Label's Control
defaults to constant Control
(i.e. it doesn't react to mouse input events). This implies that a label won't display any configured Control
, unless you change its mouse filter.
Properties
Name | Type | Description |
---|---|---|
_align [get, set]
|
Label | Controls the text's horizontal align. Supports left, center, right, and fill, or justify. Set it to one of the align constants.
|
autowrap [get, set]
|
bool | 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.
|
clipText [get, set]
|
bool | If true , the Label only shows the text that fits inside its bounding rectangle. It also lets you scale the node down freely.
|
linesSkipped [get, set]
|
long | The node ignores the first lines_skipped lines before it starts to display text.
|
maxLinesVisible [get, set]
|
long | Limits the lines of text the node shows on screen. |
percentVisible [get, set]
|
double | 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.
|
text [get, set]
|
String | The text to display on screen. |
uppercase [get, set]
|
bool | If true , all the text displays as UPPERCASE.
|
valign [get, set]
|
Label | Controls the text's vertical align. Supports top, center, bottom, and fill. Set it to one of the valign constants.
|
visibleCharacters [get, set]
|
long | Restricts the number of characters to display. Set to -1 to disable. |
Methods
Name | Description |
---|---|
getAlign
|
|
getLineCount
|
Returns the amount of lines of text the Label has. |
getLineHeight
|
Returns the font size in pixels. |
getLinesSkipped
|
|
getMaxLinesVisible
|
|
getPercentVisible
|
|
getText
|
|
getTotalCharacterCount
|
Returns the total number of printable characters in the text (excluding spaces and newlines). |
getValign
|
|
getVisibleCharacters
|
|
getVisibleLineCount
|
Returns the number of lines shown. Useful if the Label 's height cannot currently display all lines.
|
hasAutowrap
|
|
isClippingText
|
|
isUppercase
|
|
setAlign
|
|
setAutowrap
|
|
setClipText
|
|
setLinesSkipped
|
|
setMaxLinesVisible
|
|
setPercentVisible
|
|
setText
|
|
setUppercase
|
|
setValign
|
|
setVisibleCharacters
|
Enums
Name | Description |
---|---|
Align
|
|
Constants
|
|
VAlign
|