Label

package
v0.0.0-...-a235115 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

A control for displaying plain text. 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 rich text formatting. For that, use RichTextLabel instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsLabel() Instance
}

type Expanded

type Expanded = MoreArgs

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsCanvasItem

func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance

func (*Extension[T]) AsControl

func (self *Extension[T]) AsControl() Control.Instance

func (*Extension[T]) AsLabel

func (self *Extension[T]) AsLabel() Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.Label

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsCanvasItem

func (self Instance) AsCanvasItem() CanvasItem.Instance

func (Instance) AsControl

func (self Instance) AsControl() Control.Instance

func (Instance) AsLabel

func (self Instance) AsLabel() Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AutowrapMode

func (self Instance) AutowrapMode() TextServer.AutowrapMode

If set to something other than [Textserver.AutowrapOff], the text gets wrapped inside the node's bounding rectangle. If you resize the node, it will change its height automatically to show all the text.

func (Instance) AutowrapTrimFlags

func (self Instance) AutowrapTrimFlags() TextServer.LineBreakFlag

Autowrap space trimming flags. See [Textserver.BreakTrimStartEdgeSpaces] and [Textserver.BreakTrimEndEdgeSpaces] for more info.

func (Instance) ClipText

func (self Instance) ClipText() bool

If true, the Label only shows the text that fits inside its bounding rectangle and will clip text horizontally.

func (Instance) EllipsisChar

func (self Instance) EllipsisChar() string

Ellipsis character used for text clipping.

func (Instance) GetCharacterBounds

func (self Instance) GetCharacterBounds(pos int) Rect2.PositionSize

Returns the bounding rectangle of the character at position 'pos' in the label's local coordinate system. If the character is a non-visual character or 'pos' is outside the valid range, an empty Rect2.PositionSize is returned. If the character is a part of a composite grapheme, the bounding rectangle of the whole grapheme is returned.

func (Instance) GetLineCount

func (self Instance) GetLineCount() int

Returns the number of lines of text the Label has.

func (Instance) GetLineHeight

func (self Instance) GetLineHeight() int

Returns the height of the line 'line'.

If 'line' is set to -1, returns the biggest line height.

If there are no lines, returns font size in pixels.

func (Instance) GetTotalCharacterCount

func (self Instance) GetTotalCharacterCount() int

Returns the total number of printable characters in the text (excluding spaces and newlines).

func (Instance) GetVisibleLineCount

func (self Instance) GetVisibleLineCount() int

Returns the number of lines shown. Useful if the Label's height cannot currently display all lines.

func (Instance) HorizontalAlignment

func (self Instance) HorizontalAlignment() GUI.HorizontalAlignment

Controls the text's horizontal alignment. Supports left, center, right, and fill (also known as justify).

func (Instance) ID

func (self Instance) ID() ID

func (Instance) JustificationFlags

func (self Instance) JustificationFlags() TextServer.JustificationFlag

Line fill alignment rules.

func (Instance) LabelSettings

func (self Instance) LabelSettings() LabelSettings.Instance

A LabelSettings resource that can be shared between multiple Label nodes. Takes priority over theme properties.

func (Instance) Language

func (self Instance) Language() string

Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.

func (Instance) LinesSkipped

func (self Instance) LinesSkipped() int

The number of the lines ignored and not displayed from the start of the Text value.

func (Instance) MaxLinesVisible

func (self Instance) MaxLinesVisible() int

Limits the lines of text the node shows on screen.

func (Instance) MoreArgs

func (self Instance) MoreArgs() MoreArgs

MoreArgs enables certain functions to be called with additional 'optional' arguments.

func (Instance) ParagraphSeparator

func (self Instance) ParagraphSeparator() string

String used as a paragraph separator. Each paragraph is processed independently, in its own BiDi context.

func (Instance) SetAutowrapMode

func (self Instance) SetAutowrapMode(value TextServer.AutowrapMode)

SetAutowrapMode sets the property returned by [GetAutowrapMode].

func (Instance) SetAutowrapTrimFlags

func (self Instance) SetAutowrapTrimFlags(value TextServer.LineBreakFlag)

SetAutowrapTrimFlags sets the property returned by [GetAutowrapTrimFlags].

func (Instance) SetClipText

func (self Instance) SetClipText(value bool)

SetClipText sets the property returned by [IsClippingText].

func (Instance) SetEllipsisChar

func (self Instance) SetEllipsisChar(value string)

SetEllipsisChar sets the property returned by [GetEllipsisChar].

func (Instance) SetHorizontalAlignment

func (self Instance) SetHorizontalAlignment(value GUI.HorizontalAlignment)

SetHorizontalAlignment sets the property returned by [GetHorizontalAlignment].

func (Instance) SetJustificationFlags

func (self Instance) SetJustificationFlags(value TextServer.JustificationFlag)

SetJustificationFlags sets the property returned by [GetJustificationFlags].

func (Instance) SetLabelSettings

func (self Instance) SetLabelSettings(value LabelSettings.Instance)

SetLabelSettings sets the property returned by [GetLabelSettings].

func (Instance) SetLanguage

func (self Instance) SetLanguage(value string)

SetLanguage sets the property returned by [GetLanguage].

func (Instance) SetLinesSkipped

func (self Instance) SetLinesSkipped(value int)

SetLinesSkipped sets the property returned by [GetLinesSkipped].

func (Instance) SetMaxLinesVisible

func (self Instance) SetMaxLinesVisible(value int)

SetMaxLinesVisible sets the property returned by [GetMaxLinesVisible].

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetParagraphSeparator

func (self Instance) SetParagraphSeparator(value string)

SetParagraphSeparator sets the property returned by [GetParagraphSeparator].

func (Instance) SetStructuredTextBidiOverride

func (self Instance) SetStructuredTextBidiOverride(value TextServer.StructuredTextParser)

SetStructuredTextBidiOverride sets the property returned by [GetStructuredTextBidiOverride].

func (Instance) SetStructuredTextBidiOverrideOptions

func (self Instance) SetStructuredTextBidiOverrideOptions(value []any)

SetStructuredTextBidiOverrideOptions sets the property returned by [GetStructuredTextBidiOverrideOptions].

func (Instance) SetTabStops

func (self Instance) SetTabStops(value []float32)

SetTabStops sets the property returned by [GetTabStops].

func (Instance) SetText

func (self Instance) SetText(value string)

SetText sets the property returned by [GetText].

func (Instance) SetTextDirection

func (self Instance) SetTextDirection(value Control.TextDirection)

SetTextDirection sets the property returned by [GetTextDirection].

func (Instance) SetTextOverrunBehavior

func (self Instance) SetTextOverrunBehavior(value TextServer.OverrunBehavior)

SetTextOverrunBehavior sets the property returned by [GetTextOverrunBehavior].

func (Instance) SetUppercase

func (self Instance) SetUppercase(value bool)

SetUppercase sets the property returned by [IsUppercase].

func (Instance) SetVerticalAlignment

func (self Instance) SetVerticalAlignment(value GUI.VerticalAlignment)

SetVerticalAlignment sets the property returned by [GetVerticalAlignment].

func (Instance) SetVisibleCharacters

func (self Instance) SetVisibleCharacters(value int)

SetVisibleCharacters sets the property returned by [GetVisibleCharacters].

func (Instance) SetVisibleCharactersBehavior

func (self Instance) SetVisibleCharactersBehavior(value TextServer.VisibleCharactersBehavior)

SetVisibleCharactersBehavior sets the property returned by [GetVisibleCharactersBehavior].

func (Instance) SetVisibleRatio

func (self Instance) SetVisibleRatio(value Float.X)

SetVisibleRatio sets the property returned by [GetVisibleRatio].

func (Instance) StructuredTextBidiOverride

func (self Instance) StructuredTextBidiOverride() TextServer.StructuredTextParser

Set BiDi algorithm override for the structured text.

func (Instance) StructuredTextBidiOverrideOptions

func (self Instance) StructuredTextBidiOverrideOptions() []any

Set additional options for BiDi override.

func (Instance) TabStops

func (self Instance) TabStops() []float32

Aligns text to the given tab-stops.

func (Instance) Text

func (self Instance) Text() string

The text to display on screen.

func (Instance) TextDirection

func (self Instance) TextDirection() Control.TextDirection

Base text writing direction.

func (Instance) TextOverrunBehavior

func (self Instance) TextOverrunBehavior() TextServer.OverrunBehavior

The clipping behavior when the text exceeds the node's bounding rectangle.

func (Instance) Uppercase

func (self Instance) Uppercase() bool

If true, all the text displays as UPPERCASE.

func (Instance) VerticalAlignment

func (self Instance) VerticalAlignment() GUI.VerticalAlignment

Controls the text's vertical alignment. Supports top, center, bottom, and fill.

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

func (Instance) VisibleCharacters

func (self Instance) VisibleCharacters() int

The number of characters to display. If set to -1, all characters are displayed. This can be useful when animating the text appearing in a dialog box.

Note: Setting this property updates VisibleRatio accordingly.

Note: Characters are counted as Unicode codepoints. A single visible grapheme may contain multiple codepoints (e.g. certain emoji use three codepoints). A single codepoint may contain two UTF-16 characters, which are used in C# strings.

func (Instance) VisibleCharactersBehavior

func (self Instance) VisibleCharactersBehavior() TextServer.VisibleCharactersBehavior

The clipping behavior when VisibleCharacters or VisibleRatio is set.

func (Instance) VisibleRatio

func (self Instance) VisibleRatio() Float.X

The fraction of characters to display, relative to the total number of characters (see GetTotalCharacterCount). If set to 1.0, all characters are displayed. If set to 0.5, only half of the characters will be displayed. This can be useful when animating the text appearing in a dialog box.

Note: Setting this property updates VisibleCharacters accordingly.

type MoreArgs

type MoreArgs [1]gdclass.Label

MoreArgs is a container for Instance functions with additional 'optional' arguments.

func (MoreArgs) GetLineHeight

func (self MoreArgs) GetLineHeight(line int) int

Returns the height of the line 'line'.

If 'line' is set to -1, returns the biggest line height.

If there are no lines, returns font size in pixels.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL