![]() |
This function becomes protected when affecting frames or regions that are protected.
|
Anchors a region.
region:SetPoint(point [, ofsx, ofsy]) region:SetPoint(point, relativeTo [, ofsx, ofsy]) region:SetPoint(point, relativeTo, relativePoint [, ofsx, ofsy])
Arguments
- point
- string - One of the region's anchors (e.g. "TOPLEFT").
- relativeTo
- Region|string - Another region to align against (or its name); defaults to the region's parent if it has one, or the entire screen.
- relativePoint
- string - An anchor on the other region (or entire screen) to align against; defaults to point.
- ofsx
- number? - Offset right (negative for left); defaults to 0 and requires ofsy.
- ofsy
- number? - Offset down (negative for up); defaults to 0 and requires ofsx.
Details
- Omitting relativeTo or relativePoint shifts later arguments forward.
- Repeated assignment to the same point will overwrite previous ones.
- UI scaling affects the distances for ofsx and ofsy; increasing the Region's scale will increase the offset.
- See Region:IsRectValid() for further guidance on valid combinations of anchors.
- Protected frames may silently ignore calls to this function if the relative frame is a FontString.
Examples
Overwrites the same point several times, yet each call has the same outcome of anchoring to the bottom-left corner of UIParent:
local frame = CreateFrame("Frame", nil, UIParent) -- UIParent is the parent
frame:SetPoint("BOTTOMLEFT")
frame:SetPoint("BOTTOMLEFT", 0, 0)
frame:SetPoint("BOTTOMLEFT", UIParent)
frame:SetPoint("BOTTOMLEFT", UIParent, 0, 0)
frame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT")
frame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 0, 0)
frame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 0, 0)
frame:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 0, 0)
Patch changes
Patch 8.2.0 (2019-06-25): "Frames that are anchored to a restricted frame can only have their other anchors set to frames within that same anchor hierarchy" (Source)
See also
- Region:GetPoint(n) - Returns a copy of the argments used to create an anchor.
- Region:GetNumPoints() - Returns the number of anchors currently set.
- Region:SetAllPoints() - Shorthand for fixing the TOPLEFT and BOTTOMRIGHT anchors to the parent without offset.
- Region:ClearAllPoints() - Clears any set anchors.
- GameTooltip:SetOwner - Securely positions the GameTooltip in lieu of SetPoint()