Label Element
Label is a basic UI element in Weo, used to display text within a RenderSurface.
Label Element Element
Constructor
Label.new() Function
Label.new(RenderSurface, LabelProperties)
- Creates a new
Labelon the givenRenderSurface.
Parameters:
-
RenderSurfaceRenderSurface- The RenderSurface where the Label will be rendered.
-
LabelPropertiestable-
A table containing properties for the Label.
-
absolutetable— READONLY: Absolute position and size of the Label. Changing this property has no effect.-
Table containing absolute position and size:
positionVector2— Absolute position of the Label.sizeVector2— Absolute size of the Label.
-
-
positionUDim2— Position of the Label. -
sizeVector2— READONLY: Size of the Label, determined automatically by theRenderSurface:measure(text)method. Padding andUDim2.*.Scaleshould work as expected. -
textstring— Text content of the Label. -
fontstring— Font of the Label. -
fontsizenumber— Font size of the Label. -
fontstyleEnum.FontStyle— Font style of the Label. -
fontweightnumber— Font weight of the Label. -
textcolornumber?LinearGradient?RadialGradient?— Text color of the Label. -
zIndexnumber?— Z-index of the Label. -
parentany— Parent container of the Label. -
cursorstring?— Cursor style of the Label. -
opacitynumber?— Opacity of the Label. This overwrites thetextcolorproperty. Does not applies toGradienttypes. -
classtable?— Class of the Label,for theThemeService.- Table containing class properties:
- This property expects
table<string|nil>|nil.
- This property expects
- Table containing class properties:
-
paddingtable?— Padding of the Frame.- Table containing padding properties:
topnumber?— Top padding of the Frame.bottomnumber?— Bottom padding of the Frame.leftnumber?— Left padding of the Frame.rightnumber?— Right padding of the Frame.
- Table containing padding properties:
-
Methods
(Label):Destroy() Function
- Destroys the
Labeland all its children.
Calling
:Destroy()does not set your variable tonil. The object will no longer be rendered or functional, but the Lua variable holding the reference. You must set object tonilif you want to allow the object to be garbage collected.
(Label):show() Function
- Makes the
Labelvisible.
(Label):hide() Function
- Hides the
Label.
Signals
(Label).MouseHover Signal
- Fires when the mouse hovers over the Label.
Parameters:
- position Vector2— hover position relative to the window
-
buttons
table— mouse buttons state-
Table containing mouse button states:
left— Left mouse button state.middle— Middle mouse button state.right— Right mouse button state.control— Control key state.shift— Shift key state.
-
(Label).MouseButton1Click Signal
- Fires when the Label is clicked with the left mouse button.
Parameters:
- position Vector2— click position relative to the window
(Label).MouseButton2Click Signal
- Fires when the Label is clicked with the right mouse button.
Parameters:
- position Vector2— click position relative to the window
(Label).MouseButtonDown Signal
- Fires when a mouse button is pressed down on the Label.
Parameters:
- position Vector2— mouse position relative to the window
-
buttons
table— mouse buttons state-
Table containing mouse button states:
left— Left mouse button state.middle— Middle mouse button state.right— Right mouse button state.control— Control key state.shift— Shift key state.
-
(Label).MouseButtonUp Signal
- Fires when a mouse button is released on the Label.
Parameters:
- position Vector2— mouse position relative to the window
-
buttons
table— mouse buttons state-
Table containing mouse button states:
left— Left mouse button state.middle— Middle mouse button state.right— Right mouse button state.control— Control key state.shift— Shift key state.
-
(Label).MouseWheel Signal
- Fires when the mouse wheel is scrolled while hovering over the Label.
Parameters:
- delta number— scroll amount
(Label).MouseLeave Signal
- Fires when the mouse leaves the Label area.
Parameters:
- position Vector2— last mouse position before leaving
-
buttons
table— mouse buttons state-
Table containing mouse button states:
left— Left mouse button state.middle— Middle mouse button state.right— Right mouse button state.control— Control key state.shift— Shift key state.
-
(Label).Shown Signal
- Fires when the Label becomes visible.
(Label).Hidden Signal
- Fires when the Label is hidden.
(Label).Destroyed Signal
- Fires when the Label is destroyed.
Example
local label = Label.new(RenderSurface, {
position = UDim2.new(0, 20, 0, 20),
text = "Hello World",
font = "Arial",
fontsize = 16,
fontstyle = Enum.FontStyle.Normal,
fontweight = 400,
textcolor = Color.fromRGBA(255, 255, 255, 255),
zIndex = 1,
parent = FrameInstance,
})
label.MouseButton1Click:Connect(function(p)
print("Label clicked at:", p.x, p.y)
end)
Notes
absoluteandsizeare read-only; usepositionandRenderSurface:measure(text)to handle layout and sizing.
- First argument of
Label.new()should be an instance ofRenderSurface,it's not theparentof the label. You must setparentinLabelProperties.