• Getting a DLabel's height with wrapping enabled
    1 replies, posted
Hello, I'm trying to make an announcement VGUI and DLabels are being assholes (or maybe I am). I'm trying to get a DLabel's height so I can update the PANEL's height and am terrible failing. [LUA] function PANEL:Init() self.title = self:Add("DLabel") self.title:SetPos(5, 0) self.title:SetColor(Color(255, 255, 255)) self.title:SetExpensiveShadow(1, Color(0, 0, 0)) self.title:SetContentAlignment(7) self.title:SetFont("TitleFont") self.title:SetText("Announcement") self.title:SizeToContents() self.text = self:Add("DLabel") self.text:SetPos(10, 35) self.text:SetColor(Color(255, 255, 255)) self.text:SetExpensiveShadow(1, Color(0, 0, 0)) self.text:SetContentAlignment(7) self.text:SetText("Hello there!\nThe server will be shut down for maintenance tomorrow at 9PM for about 30 minutes.\n\nBye!") self.text:SetWide(290) self.text:SetWrap(true) self.text:SetAutoStretchVertical(true) -- Doesn't update the height value //self.text:SizeToContentsY() -- Sets Y to a ridiculous value (> 1400) print(self.text:GetTall()) -- Returns 20 whatever the text end [/LUA] [I]PANEL is a DPanel[/I] Please send help.
I'm now using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/markup/Parse]markup.Parse[/url] as the wrapping is way more reliable.
Sorry, you need to Log In to post a reply to this thread.