phantomwhale
April 2nd, 2012, 10:46
Been bashing me head at an issue of getting the size of a control during it's onInit() method.
the getSize() method always returns 0,0 until after initialize, and there is no event for me to hook into like "once everything is initialized and has got it's size determined" ! (or is there ?)
One workaround has been to "cheat" and do the following :
local controlwidth, controlheight = getSize()
if controlwidth == 0 or controlheight == 0 and anchored and anchored[1] and anchored.size and anchored.size[1] then
controlwidth, controlheight = tonumber(anchored[1].size[1].width[1]), tonumber(anchored[1].size[1].height[1]);
end
But this obviously relies on the control having a size and height defined - which in my case it didn't (it uses a left and right anchor) but I can define one just for the purpose of getting the workaround working.
So is there any event or trick I can use to redraw a window control as soon as it's getSize() method is going to return non-zero numbers ?
the getSize() method always returns 0,0 until after initialize, and there is no event for me to hook into like "once everything is initialized and has got it's size determined" ! (or is there ?)
One workaround has been to "cheat" and do the following :
local controlwidth, controlheight = getSize()
if controlwidth == 0 or controlheight == 0 and anchored and anchored[1] and anchored.size and anchored.size[1] then
controlwidth, controlheight = tonumber(anchored[1].size[1].width[1]), tonumber(anchored[1].size[1].height[1]);
end
But this obviously relies on the control having a size and height defined - which in my case it didn't (it uses a left and right anchor) but I can define one just for the purpose of getting the workaround working.
So is there any event or trick I can use to redraw a window control as soon as it's getSize() method is going to return non-zero numbers ?