ScriptRegion:IsRectValid
Jump to navigation
Jump to search
ScriptRegion:GetRect |
||
ScriptRegion:GetScaledRect |
||
ScriptRegion:IsRectValid |
Returns true if the region can be positioned on the screen.
isValid = ScriptRegion:IsRectValid()
Returns
- isValid
- boolean - true if the region is a valid rectangle.
Details
Valid regions must have either:
- Two opposite corners from SetPoint or SetAllPoints.
- One point from SetPoint and an explicit size (width, height) from SetSize.
For newly created regions, requires the client to have rendered the next frame before the rect is resolved and returns true. This can also be resolved during the same frame by calling GetSize / GetWidth / GetHeight.
Example
Creates a frame and calls AnchorUtil.PrintAnchorGraph. Note that this implicitly calls GetSize
.
local f = CreateFrame("Frame", "SomeFrame", UIParent)
f:SetPoint("CENTER")
f:SetSize(100, 100)
print(f:IsRectValid()) -- false
AnchorUtil.PrintAnchorGraph(f)
print(f:IsRectValid()) -- true
AnchorUtil.PrintAnchorGraph(f)
When rects are resolved
The renderer will only resolve rects on the next frame or when methods like GetSize force it to resolve the rects.
local f = CreateFrame("Frame")
f:SetPoint("CENTER")
f:SetSize(100, 100)
f.tex = f:CreateTexture()
f.tex:SetColorTexture(1, 1, 0)
f.tex:SetAllPoints()
-- rects will be invalid on the next frame
f:ClearAllPoints() -- not visible
-- rects are forced to be validated beforehand
f:GetSize()
f:ClearAllPoints() -- visible
This generally does not invalidate rects once validated, i.e. after calling ClearAllPoints()
the region will still be visible.
C_Timer.After(0, function() f:ClearAllPoints(); print(f:IsRectValid()) end) -- visible, true
Patch changes
Patch 7.3.2 (2017-10-24): Added.