Just something I happened upon that had me completely stumped.
The height of
scroll here comes out as 0 due to this very specific combination of things.
Code:
local frame = CreateFrame("Frame")
local container = CreateFrame("Frame", nil, frame)
container:SetAllPoints()
local scroll = CreateFrame("Frame", nil, container)
scroll:SetAllPoints()
local button = CreateFrame("Button", nil, container)
button:SetPoint("CENTER")
button:SetNormalTexture([[Interface\ChatFrame\UI-ChatIcon-ScrollDown-Up]])
frame:SetSize(24, 16)
frame:SetPoint("CENTER")
print(scroll:GetHeight())
The key here (everything is really the key, but the very core key) is the call to button:SetNormalTexture. That was the first thing that I removed that fixed the problem, and printed the true size of scroll.
Some of my observations (to reproduce the bug)
- First of all, frame:SetSize and frame:SetPoint must come after button:SetNormalTexture
- button:SetNormalTexture must come after button:SetPoint
- scroll and button must be at least grandchildren (no closer) of frame, but they don't have to be siblings
- Pushed and Disabled texture produces the same result, but not Highlight texture
- It doesn't have to be a valid texture
So the fix, while retaining all other code, is to set
button's point after setting its textures...
Case in point;
frame is my main frame, whose point and size I set on ADDON_LOADED,
scroll is a scroll frame whose height I need to determine to create appropriate amount of buttons once frame is sized.