• Property sheets and parenting
    3 replies, posted
Ok, so I'm making a derma menu with tabs, but the text seems to appear at the top left. I haven't parented it to anything, but I did add it to the property sheet. Can anyone help ? :) [lua] local function f1menuderma() local frame = vgui.Create("DFrame") frame:SetPos(530,230) frame:SetSize( 800, 600 ) frame:SetTitle("F1 menu") frame:SetVisible(true) frame:SetDraggable(true) frame:MakePopup() frame:SetSkin("DarkRP") local propertysheet = vgui.Create("DPropertySheet") -- This is attatched to the frame -- propertysheet:SetParent(frame) propertysheet:SetPos(30,30) -- You could modify the sheet's position on the frame. propertysheet:SetSize( 740, 540 ) local welcometext = vgui.Create( "DPanel") -- welcometext:SetPos( 0,0 ) -- welcometext:SetSize(ScrW()/2 -10,ScrH()/2 - 60) -- welcometext:SetParent(propertysheet) welcometext.Paint = function() surface.SetFont( "default" ) -- font surface.SetTextColor( 255, 255, 255, 255 ) -- colour surface.SetTextPos( 0, 0 ) -- leave this surface.DrawText( "text" ) -- Edit this to edit the welcome's text end propertysheet:AddSheet("Welcome", welcometext, "gui/silkicons/user", false, false, "Welcome") end [/lua]
It appears at the top left because of this. surface.SetTextPos( 0, 0 ) 0, 0 is the top left.
[QUOTE=sintwins;20022936]Ok, so I'm making a derma menu with tabs, but the text seems to appear at the top left. I haven't parented it to anything, but I did add it to the property sheet. Can anyone help ? :)[/QUOTE] You'd probably be better off using a DLabel for writing that text instead of apparently re-implementing it. [lua]local welcometext = vgui.Create( "DPanel") -- welcometext:SetPos( 0,0 ) -- welcometext:SetSize(ScrW()/2 -10,ScrH()/2 - 60) -- welcometext:SetParent(propertysheet) welcometext.Paint = function() surface.SetFont( "default" ) -- font surface.SetTextColor( 255, 255, 255, 255 ) -- colour surface.SetTextPos( 0, 0 ) -- leave this surface.DrawText( "text" ) -- Edit this to edit the welcome's text end[/lua] Is roughly equivalent to [lua]local welcometext = vgui.Create("DLabel") welcometext:SetText("text") [/lua]
Thanks I'll try that later :)
Sorry, you need to Log In to post a reply to this thread.