no edit summary
No edit summary |
|||
| Line 81: | Line 81: | ||
However, calling SetWidth() with your object's actual width (which you can't get via GetWidth(), but you can try GetLeft()-GetRight()), and calling GetHeight() will still tell you how high the object actually needs to be. | However, calling SetWidth() with your object's actual width (which you can't get via GetWidth(), but you can try GetLeft()-GetRight()), and calling GetHeight() will still tell you how high the object actually needs to be. | ||
If you want to completely clear width or height once set to have WoW start returning computed values for you, you need to call SetWidth(0) or SetHeight(0). | If you want to completely clear width or height once set to have WoW start returning computed values for you, you need to call SetWidth(0) or SetHeight(0). | ||
</div> | |||
=== Code example === | |||
<div style="margin-left: 3%;"> | |||
This example will rescale a frame to fit the text. On all four sides a 5px margin is made. | |||
text:SetPoint("TOPLEFT",frame,"TOPLEFT",5,-5) | |||
text:SetWidth(frame:GetRight() - frame:GetLeft() - 10) | |||
frame:SetHeight(text:GetHeight() + 15) | |||
Note that the number returned by text:GetHeight() will typically be slighly less than the actual height of the text. Including a 5px margin (both top and bottom), the height of the frame is therefor set to the text height plus 15px. | |||
</div> | |||
</div> | </div> | ||
[[Category:Widgets]] | [[Category:Widgets]] | ||