Frame is in many ways the most fundamental widget object. Other types of widget derivatives such as FontStrings, Textures and Animations can only be created attached to a Frame or other derivative of a Frame. Frames provide the basis for interaction with the user, and registering and responding to game events.
When an addon needs to respond to game events or state changes and needs no visible components, this is typically accomplished using a Frame. Visibly, widgets that display game information such as threat or cooldowns and aren't directly interactive beyond being draggable are typically Frames. They are also commonly used as ways to group other related frames, either visibly (such as the way the Talents pane groups the buttons representing your character's talents) or invisibly (such as the way MultiBarRight groups twelve action buttons).
You create a plain frame by specifying "Frame" as the first argument to CreateFrame, or with a <Frame> element in an XML file:
-- Create a new frame in Lua
local self = CreateFrame("Frame", "FunWidget", UIParent)
<Frame name="FunWidget" parent="UIParent">
<!-- insert anchors, scripts, children and other components here in XML -->
</Frame>
Frames in the FrameXML include the action bars (the frames that group the action buttons together), the panels that display information like your character status and quest log, and the grand-daddy of the rest of the UI, UIParent.
Defined Methods
- Frame:AllowAttributeChanges() - Temporarily allows insecure code to modify the frame's attributes during combat
- enabled = Frame:CanChangeAttribute() - Returns whether secure frame attributes can currently be changed
- fontstring = Frame:CreateFontString(["name" [, "layer" [, "inherits"]]]) - Creates a new [[docs/widgets/FontString|`FontString`]] as a child of the frame
- texture = Frame:CreateTexture(["name" [, "layer" [, "inherits"]]]) - Creates a new [[docs/widgets/Texture|`Texture`]] as a child of the frame
- region = Frame:CreateTitleRegion() - Creates a title region for dragging the frame
- Frame:DisableDrawLayer("layer") - Prevents display of all child objects of the frame on a specified graphics layer
- Frame:EnableDrawLayer("layer") - Allows display of all child objects of the frame on a specified graphics layer
- Frame:EnableJoystick(enable) - Enables or disables joystick interactivity
- Frame:EnableKeyboard(enable) - Enables or disables keyboard interactivity for the frame
- Frame:EnableMouse(enable) - Enables or disables mouse interactivity for the frame
- Frame:EnableMouseWheel(enable) - Enables or disables mouse wheel interactivity for the frame
- value = Frame:GetAttribute("name") - Returns the value of a secure frame attribute
- backdrop = Frame:GetBackdrop() - Returns information about the frame's backdrop graphic
- red, green, blue, alpha = Frame:GetBackdropBorderColor() - Returns the shading color for the frame's border graphic
- red, green, blue, alpha = Frame:GetBackdropColor() - Returns the shading color for the frame's background graphic
- left, bottom, width, height = Frame:GetBoundsRect() - Returns the position and dimension of the smallest area enclosing the frame and its children
- ... = Frame:GetChildren() - Returns a list of child frames of the frame
- left, right, top, bottom = Frame:GetClampRectInsets() - Returns offsets from the frame's edges used when limiting user movement or resizing of the frame
- depth = Frame:GetDepth() - Returns the 3D depth of the frame (for stereoscopic 3D setups)
- alpha = Frame:GetEffectiveAlpha() - Returns the overall opacity of the frame
- depth = Frame:GetEffectiveDepth() - Returns the overall 3D depth of the frame (for stereoscopic 3D configurations)
- scale = Frame:GetEffectiveScale() - Returns the overall scale factor of the frame
- level = Frame:GetFrameLevel() - Sets the level at which the frame is layered relative to others in its strata
- strata = Frame:GetFrameStrata() - Returns the general layering strata of the frame
- left, right, top, bottom = Frame:GetHitRectInsets() - Returns the insets from the frame's edges which determine its mouse-interactable area
- id = Frame:GetID() - Returns the frame's numeric identifier
- maxWidth, maxHeight = Frame:GetMaxResize() - Returns the maximum size of the frame for user resizing
- minWidth, minHeight = Frame:GetMinResize() - Returns the minimum size of the frame for user resizing
- numChildren = Frame:GetNumChildren() - Returns the number of child frames belonging to the frame
- numRegions = Frame:GetNumRegions() - Returns the number of non-Frame child regions belonging to the frame
- ... = Frame:GetRegions() - Returns a list of non-Frame child regions belonging to the frame
- scale = Frame:GetScale() - Returns the frame's scale factor
- region = Frame:GetTitleRegion() - Returns the frame's TitleRegion object
- Frame:IgnoreDepth(enable) - Sets whether the frame's depth property is ignored (for stereoscopic 3D setups)
- enabled = Frame:IsClampedToScreen() - Returns whether the frame's boundaries are limited to those of the screen
- registered = Frame:IsEventRegistered("event") - Returns whether the frame is registered for a given [[docs/events|event]]
- enabled = Frame:IsIgnoringDepth() - Returns whether the frame's depth property is ignored (for stereoscopic 3D setups)
- enabled = Frame:IsJoystickEnabled() - Returns whether joystick interactivity is enabled for the frame
- enabled = Frame:IsKeyboardEnabled() - Returns whether keyboard interactivity is enabled for the frame
- enabled = Frame:IsMouseEnabled() - Returns whether mouse interactivity is enabled for the frame
- enabled = Frame:IsMouseWheelEnabled() - Returns whether mouse wheel interactivity is enabled for the frame
- movable = Frame:IsMovable() - Returns whether the frame can be moved by the user
- enabled = Frame:IsResizable() - Returns whether the frame can be resized by the user
- enabled = Frame:IsToplevel() - Returns whether the frame is automatically raised to the front when clicked
- enabled = Frame:IsUserPlaced() - Returns whether the frame is flagged for automatic saving and restoration of position and dimensions
- Frame:Lower() - Reduces the frame's frame level below all other frames in its strata
- Frame:Raise() - Increases the frame's frame level above all other frames in its strata
- Frame:RegisterAllEvents() - Registers the frame for all events
- Frame:RegisterEvent("event") - Registers the frame for an [[docs/events|event]]
- Frame:RegisterForDrag(...) - Registers the frame for dragging
- Frame:SetAttribute("name", value) - Sets a secure frame attribute
- Frame:SetBackdrop(backdrop) - Sets a backdrop graphic for the frame
- Frame:SetBackdropBorderColor(red, green, blue [, alpha]) - Sets a shading color for the frame's border graphic
- Frame:SetBackdropColor(red, green, blue [, alpha]) - Sets a shading color for the frame's background graphic
- Frame:SetClampRectInsets(left, right, top, bottom) - Sets offsets from the frame's edges used when limiting user movement or resizing of the frame
- Frame:SetClampedToScreen(enable) - Sets whether the frame's boundaries should be limited to those of the screen
- Frame:SetDepth(depth) - Sets the 3D depth of the frame (for stereoscopic 3D configurations)
- Frame:SetFrameLevel(level) - Sets the level at which the frame is layered relative to others in its strata
- Frame:SetFrameStrata("strata") - Sets the general layering strata of the frame
- Frame:SetHitRectInsets(left, right, top, bottom) - Sets the insets from the frame's edges which determine its mouse-interactable area
- Frame:SetID(id) - Sets a numeric identifier for the frame
- Frame:SetMaxResize(maxWidth, maxHeight) - Sets the maximum size of the frame for user resizing
- Frame:SetMinResize(minWidth, minHeight) - Sets the minimum size of the frame for user resizing
- Frame:SetMovable(enable) - Sets whether the frame can be moved by the user
- Frame:SetResizable(enable) - Sets whether the frame can be resized by the user
- Frame:SetScale(scale) - Sets the frame's scale factor
- Frame:SetToplevel(enable) - Sets whether the frame should automatically come to the front when clicked
- Frame:SetUserPlaced(enable) - Flags the frame for automatic saving and restoration of position and dimensions
- Frame:StartMoving() - Begins repositioning the frame via mouse movement
- Frame:StartSizing() - Begins resizing the frame via mouse movement
- Frame:StopMovingOrSizing() - Ends movement or resizing of the frame initiated with [[docs/widgets/Frame/StartMoving|`:StartMoving()`]] or [[docs/widgets/Frame/StartSizing|`:StartSizing()`]]
- Frame:UnregisterAllEvents() - Unregisters the frame from any [[docs/events|events]] for which it is registered
- Frame:UnregisterEvent("event") - Unregisters the frame for an event
Inherited Methods
- canChange = Frame:CanChangeProtectedState() - Returns whether protected properties of the region can be changed by non-secure scripts
- Frame:ClearAllPoints() - Removes all anchor points from the region
- animationGroup = Frame:CreateAnimationGroup(["name" [, "inheritsFrom"]]) - Creates a new AnimationGroup as a child of the region
- alpha = Frame:GetAlpha() - Returns the opacity of the region relative to its parent
- ... = Frame:GetAnimationGroups() - Returns a list of animation groups belonging to the region
- bottom = Frame:GetBottom() - Returns the distance from the bottom of the screen to the bottom of the region
- x, y = Frame:GetCenter() - Returns the screen coordinates of the region's center
- height = Frame:GetHeight() - Returns the height of the region
- left = Frame:GetLeft() - Returns the distance from the left edge of the screen to the left edge of the region
- name = Frame:GetName() - Returns the widget object's name
- numPoints = Frame:GetNumPoints() - Returns the number of anchor points defined for the region
- type = Frame:GetObjectType() - Returns the object's widget type
- parent = Frame:GetParent() - Returns the object's parent object
- point, relativeTo, relativePoint, xOffset, yOffset = Frame:GetPoint(index) - Returns information about one of the region's anchor points
- left, bottom, width, height = Frame:GetRect() - Returns the position and dimensions of the region
- right = Frame:GetRight() - Returns the distance from the left edge of the screen to the right edge of the region
- handler = Frame:GetScript("scriptType") - Returns the widget's handler function for a script
- width, height = Frame:GetSize() - Returns the width and height of the region
- top = Frame:GetTop() - Returns the distance from the bottom of the screen to the top of the region
- width = Frame:GetWidth() - Returns the width of the region
- hasScript = Frame:HasScript("scriptType") - Returns whether the widget supports a script handler
- Frame:Hide() - Hides the region
- Frame:HookScript("scriptType", handler) - Securely hooks a script handler
- isDragging = Frame:IsDragging() - Returns whether the region is currently being dragged
- isOver = Frame:IsMouseOver() - Returns whether the mouse cursor is over the given region
- isType = Frame:IsObjectType("type") - Returns whether the object belongs to a given widget type
- isProtected, explicit = Frame:IsProtected() - Returns whether the region is protected
- shown = Frame:IsShown() - Returns whether the region is shown
- visible = Frame:IsVisible() - Returns whether the region is visible
- Frame:SetAllPoints([region]) or Frame:SetAllPoints(["name"]) - Sets all anchor points of the region to match those of another region
- Frame:SetAlpha(alpha) - Sets the opacity of the region relative to its parent
- Frame:SetHeight(height) - Sets the region's height
- Frame:SetParent(frame) or Frame:SetParent("name") - Makes another frame the parent of this region
- Frame:SetPoint("point" [, relativeTo [, "relativePoint" [, xOffset [, yOffset]]]]) - Sets an anchor point for the region
- Frame:SetScript("scriptType", handler) - Sets the widget's handler function for a script
- Frame:SetSize(width, height) - Sets the size of the region to the specified values
- Frame:SetWidth(width) - Sets the region's width
- Frame:Show() - Shows the region
- Frame:StopAnimating() - Stops any active animations involving the region or its children
Script Handlers
- OnAttributeChanged(self, "name", value) - Run when a frame attribute is changed
- OnChar(self, "text") - Run for each text character typed in the frame
- OnDisable(self) - Run when the frame is disabled
- OnDragStart(self, "button") - Run when the mouse is dragged starting in the frame
- OnDragStop(self) - Run when the mouse button is released after a drag started in the frame
- OnEnable(self) - Run when the frame is enabled
- OnEnter(self, motion) - Run when the mouse cursor enters the frame's interactive area
- OnEvent(self, "event", ...) - Run whenever an [[docs/events|event]] fires for which the frame is registered
- OnHide(self) - Run when the frame's visbility changes to hidden
- OnKeyDown(self, "key") - Run when a keyboard key is pressed if the frame is keyboard enabled
- OnKeyUp(self, "key") - Run when a keyboard key is released if the frame is keyboard enabled
- OnLeave(self, motion) - Run when the mouse cursor leaves the frame's interactive area
- OnLoad(self) - Run when the frame is created
- OnMouseDown(self, "button") - Run when a mouse button is pressed while the cursor is over the frame
- OnMouseUp(self, "button") - Run when the mouse button is released following a mouse down action in the frame
- OnMouseWheel(self, delta) - Run when the frame receives a mouse wheel scrolling action
- OnReceiveDrag(self) - Run when the mouse button is released after dragging into the frame
- OnShow(self) - Run when the frame becomes visible
- OnSizeChanged(self, width, height) - Run when a frame's size changes
- OnUpdate(self, elapsed) - Run each time the screen is drawn by the game engine