The API is no longer being updated here until further notice. |
This function is restricted.
|
Returns the offset in pixels from the screen to the region.
left = ScriptRegion:GetLeft() right = ScriptRegion:GetRight() bottom = ScriptRegion:GetBottom() top = ScriptRegion:GetTop() x, y = ScriptRegion:GetCenter()
Returns[]
Returns nil
if the region has no points.
- left
- number? - Left side of the screen to the left edge of the region.
- right
- number? - Left side of the screen to the right edge of the region.
- bottom
- number? - Bottom side of the screen to the bottom edge of the region.
- top
- number? - Bottom side of the screen to the top edge of the region.
- x, y
- number? - Left and bottom side of the screen to the center of the region.
x = (left+right)/2
,y = (bottom+top)/2
Details[]
The returned values can have floating point rounding errors.
/dump PlayerFrame:GetRight() -- 213.00001525879
/dump Round(PlayerFrame:GetRight()) -- 213
Example[]
Video example |
---|
local f = CreateFrame("Frame", nil, nil, "BackdropTemplate")
f:SetSize(150, 150)
f:SetPoint("CENTER")
f:SetBackdrop(BACKDROP_TUTORIAL_16_16)
f:SetMovable(true)
f:SetScript("OnMouseDown", function(self, button)
self:StartMoving()
end)
f:SetScript("OnMouseUp", function(self, button)
self:StopMovingOrSizing()
self.UpdateFontstrings()
end)
local edges = {
{func = "GetBottom", point = {"BOTTOM", 0, 10}},
{func = "GetTop", point = {"TOP", 0, -10}},
{func = "GetLeft", point = {"LEFT", 10, 0}},
{func = "GetRight", point = {"RIGHT", -10, 0}},
}
local t = {}
for _, v in pairs(edges) do
t[v.func] = f:CreateFontString(nil, nil, "GameFontNormal")
t[v.func]:SetPoint(unpack(v.point))
end
function f.UpdateFontstrings()
for _, v in pairs(edges) do
local ret = Round(f[v.func](f))
t[v.func]:SetText(ret)
end
end
f.UpdateFontstrings()
|
Patch changes[]
Patch 8.2.0 (2019-06-25): Not allowed on restricted frames.