Thread Tools Display Modes
06-11-14, 09:36 AM   #1
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Indescribable, weird bug

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.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
06-11-14, 11:45 AM   #2
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Hm. What are the return values of http://wowprogramming.com/docs/widge.../GetBoundsRect or http://wowprogramming.com/docs/widgets/Region/GetRect for scroll?
  Reply With Quote
06-11-14, 12:03 PM   #3
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Returns nothing at all.
__________________
Grab your sword and fight the Horde!
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Indescribable, weird bug


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off