Frame Element
Frame is a fundamental UI element in Weo, used as a container for other UI objects.
Frame Element Element
Constructor
Frame.new() Function
Frame.new(RenderSurface, FrameProperties)
- Creates a new
Frameon the givenRenderSurface.
Parameters:
-
RenderSurfaceRenderSurface- The RenderSurface where the Frame will be rendered.
-
FramePropertiestable-
A table containing properties for the Frame.
-
absolutetable— READONLY: Absolute position and size of the Frame. Changing this property has no effect.- Table containing absolute position and size:
positionVector2— Absolute position of the Frame.sizeVector2— Absolute size of the Frame.
-
positionUDim2— Position of the Frame. -
sizeUDim2— Size of the Frame. -
bgcolornumber?LinearGradient?RadialGradient?- Background color of the Frame. -
visibleboolean?— Whether the Frame is visible. -
borderRadiusnumber?— Radius of the Frame's corners. -
zIndexnumber?— Z-index of the Frame. -
parentanyRenderSurface?— Parent container of the Frame. -
borderColornumber?— Border color of the Frame. -
borderThicknessnumber?— Border thickness of the Frame. -
cursorstring?— Cursor style of the Frame. -
opacitynumber?— Opacity of the Frame,this overwrites thebgcolorproperty. Does not applies toGradienttypes. -
classtable?— Class of the Frame,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
(Frame):Destroy() Function
- Destroys the
Frameand 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.
(Frame):show() Function
- Makes the
Framevisible.
(Frame):hide() Function
- Hides the
Frame.
Signals
(Frame).MouseHover Signal
- Fires when the mouse hovers over the Frame.
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.
- Table containing mouse button states:
(Frame).MouseButton1Click Signal
- Fires when the Frame is clicked with the left mouse button.
Parameters:
- position Vector2— click position relative to the window
(Frame).MouseButton2Click Signal
- Fires when the Frame is clicked with the right mouse button.
Parameters:
- position Vector2— click position relative to the window
(Frame).MouseButtonDown Signal
- Fires when a mouse button is pressed down on the Frame.
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.
- Table containing mouse button states:
(Frame).MouseButtonUp Signal
- Fires when a mouse button is released on the Frame.
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.
- Table containing mouse button states:
(Frame).MouseWheel Signal
- Fires when the mouse wheel is scrolled while hovering over the Frame.
Parameters:
- delta number— scroll amount
(Frame).MouseLeave Signal
- Fires when the mouse leaves the Frame 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.
- Table containing mouse button states:
(Frame).Shown Signal
- Fires when the Frame becomes visible.
(Frame).Hidden Signal
- Fires when the Frame is hidden.
(Frame).Destroyed Signal
- Fires when the Frame is destroyed.
Example
local frame = Frame.new(RenderSurface, {
position = UDim2.new(0, 50, 0, 50),
size = UDim2.new(0, 200, 0, 150),
bgcolor = Color.fromRGBA(30, 30, 30, 255),
borderRadius = 8,
visible = true,
zIndex = 1,
})
frame.MouseButton1Click:Connect(function(p)
print("Frame clicked at:", p.x, p.y)
end)
Notes
absoluteis read-only and should only be used for layout checks.- First argument of
Frame.new()should be an instance ofRenderSurface,it's not theparentof the frame. You must setparentinFrameProperties.