Skip to main content

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 Label on the given RenderSurface.

Parameters:

  • RenderSurface

    RenderSurface

    • The RenderSurface where the Label will be rendered.
  • LabelProperties

    table

    • A table containing properties for the Label.

    • absolute

      table
      READONLY: Absolute position and size of the Label. Changing this property has no effect.

      • Table containing absolute position and size:

        • position
          Vector2
          — Absolute position of the Label.
        • size
          Vector2
          — Absolute size of the Label.
    • position

      UDim2
      — Position of the Label.

    • size

      Vector2
      READONLY: Size of the Label, determined automatically by the RenderSurface:measure(text) method. Padding and UDim2.*.Scale should work as expected.

    • text

      string
      — Text content of the Label.

    • font

      string
      — Font of the Label.

    • fontsize

      number
      — Font size of the Label.

    • fontstyle

      Enum.FontStyle
      — Font style of the Label.

    • fontweight

      number
      — Font weight of the Label.

    • textcolor

      number?
      LinearGradient?
      RadialGradient?
      — Text color of the Label.

    • zIndex

      number?
      — Z-index of the Label.

    • parent

      any
      — Parent container of the Label.

    • cursor

      string?
      — Cursor style of the Label.

    • opacity

      number?
      — Opacity of the Label. This overwrites the textcolor property. Does not applies to Gradient types.

    • class

      table?
      — Class of the Label,for the ThemeService.

      • Table containing class properties:
        • This property expects table<string|nil>|nil.
    • padding

      table?
      — Padding of the Frame.

      • Table containing padding properties:
        • top
          number?
          — Top padding of the Frame.
        • bottom
          number?
          — Bottom padding of the Frame.
        • left
          number?
          — Left padding of the Frame.
        • right
          number?
          — Right padding of the Frame.

Methods

(Label):Destroy()
Function

  • Destroys the Label and all its children.

Calling :Destroy() does not set your variable to nil. The object will no longer be rendered or functional, but the Lua variable holding the reference. You must set object to nil if you want to allow the object to be garbage collected.

(Label):show()
Function

  • Makes the Label visible.

(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

  • absolute and size are read-only; use position and RenderSurface:measure(text) to handle layout and sizing.
  • First argument of Label.new() should be an instance of RenderSurface,it's not the parent of the label. You must set parent in LabelProperties.