• Little problem : Align text in DTextEntry
    6 replies, posted
Hey ! I have a little problem with my DTextEntry : I want to center align my text in my textbox... I have this : [IMG]http://puu.sh/auEiI/b15462be61.png[/IMG] and i want this : [IMG]http://puu.sh/auEkt/e4a6a76f76.png[/IMG] How i can do that ? Thx !
When i tried to do something like that, i overrided the Paint function, actually i weren't able to select the text
Is this even possible? I'm pretty sure the text inside the text entry is all handled in the engine. However, you can try a real hacky workaround by using this '[URL="http://wiki.garrysmod.com/page/VGUI/Elements/DTextEntry/OnValueChange"]DTextEntry:OnValueChange()[/URL]' and adding spaces appropriately to try and push your actual text into the centre.
You can use PaintOver with what Braden said and align it with something like [code] draw.DrawText(DTextEntry:GetValue(), "DermaLarge", 0, 0, Color(255, 255, 255), TEXT_ALIGN_CENTER) [/code] however if it gets too long it won't really work out..
DTextEntry:SetContentAlignment( 5 ) maybe? [url=http://wiki.garrysmod.com/page/Panel/SetContentAlignment]Panel:SetContentAlignment[/url]
Nop. SetContentAlignment doesent work : [CODE] --EYE ANGLE OWNER local OwnerAngBox = vgui.Create("DTextEntry", OwnerPanel) OwnerAngBox:SetText( tostring( math.Round( ply:EyeAngles().x , 3) ) .. "," .. tostring( math.Round( ply:EyeAngles().y , 3) ) .. "," .. tostring( math.Round( ply:EyeAngles().z , 3) ) ) OwnerAngBox:SetPos(10,90) OwnerAngBox:SetContentAlignment( 5 ) OwnerAngBox:SetSize(160,20) OwnerAngBox:SetEditable(false) [/CODE]
Looking at the engine control ( TextEntry.h ), this isn't supported out of the box - you'll have to do the painting yourself, unfortunately.
Sorry, you need to Log In to post a reply to this thread.