• Need help Making a Derma Button Open another Derma Menu
    4 replies, posted
Hey all, Its Jacklin again. So very quickly, I have a derma that has a button called Group, what I want it todo on being pressed is to Close its current menu called Menu which is does and then open another Menu called GroupMenu, I have a function to close the previous menu but Im not sure what to call for it to open a different menu, here is the 2 derma's: [CODE] // Derma Menu For Clients net.Receive( 'Menu', function() local base = vgui.Create( 'DFrame' ) base:SetSize( 600,300 ) base:Center() base:SetTitle( 'Player Basic Commands' ) base:SetDraggable( false ) base:ShowCloseButton( true ) base:MakePopup() function base:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, YEL ) surface.SetDrawColor( 0, 0, 0 ) surface.DrawOutlinedRect( 1, 1, w, h ) end local KillButt = vgui.Create( 'DButton', base ) KillButt:SetParent( base ) KillButt:SetPos( 25, 25 ) KillButt:SetSize( 100, 50 ) KillButt:SetText( 'Kill' ) function KillButt:DoClick() chat.AddText( Color( 255, 150, 0 ), "[TLDR] ", Color( 255, 255, 255 ), "What? You thought it was going to be that easy " ..LocalPlayer():Nick().. "?" ) end function KillButt:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, WHT ) end local GroupButt = vgui.Create( 'DButton', base ) GroupButt:SetParent( base ) GroupButt:SetPos( 130, 25 ) GroupButt:SetSize( 100, 50 ) GroupButt:SetText( 'Group' ) // HERE is where it closes the menu function GroupButt:DoClick() base:Close() end function GroupButt:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, WHT ) end end ) // HERE is my second Menu, Group Menu net.Receive( 'GroupMenu', function() local base = vgui.Create( 'DFrame' ) base:SetSize( 600,300 ) base:Center() base:SetTitle( 'Group Controls' ) base:SetDraggable( false ) base:ShowCloseButton( true ) base:MakePopup() function base:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, YEL ) surface.SetDrawColor( 0, 0, 0 ) surface.DrawOutlinedRect( 1, 1, w, h ) end end ) [/CODE] Hope someone can help! -Jacklin :D
Make a local function to open the Group Menu. [lua] // Derma Menu For Clients net.Receive( 'Menu', function() local base = vgui.Create( 'DFrame' ) base:SetSize( 600,300 ) base:Center() base:SetTitle( 'Player Basic Commands' ) base:SetDraggable( false ) base:ShowCloseButton( true ) base:MakePopup() function base:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, YEL ) surface.SetDrawColor( 0, 0, 0 ) surface.DrawOutlinedRect( 1, 1, w, h ) end local KillButt = vgui.Create( 'DButton', base ) KillButt:SetParent( base ) KillButt:SetPos( 25, 25 ) KillButt:SetSize( 100, 50 ) KillButt:SetText( 'Kill' ) function KillButt:DoClick() chat.AddText( Color( 255, 150, 0 ), "[TLDR] ", Color( 255, 255, 255 ), "What? You thought it was going to be that easy " ..LocalPlayer():Nick().. "?" ) end function KillButt:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, WHT ) end local GroupButt = vgui.Create( 'DButton', base ) GroupButt:SetParent( base ) GroupButt:SetPos( 130, 25 ) GroupButt:SetSize( 100, 50 ) GroupButt:SetText( 'Group' ) // HERE is where it closes the menu function GroupButt:DoClick() base:Close() // call local function OpenGroupMenu OpenGroupMenu() end function GroupButt:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, WHT ) end end ) // HERE is my second Menu, Group Menu local function OpenGroupMenu() local base = vgui.Create( 'DFrame' ) base:SetSize( 600,300 ) base:Center() base:SetTitle( 'Group Controls' ) base:SetDraggable( false ) base:ShowCloseButton( true ) base:MakePopup() function base:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, YEL ) surface.SetDrawColor( 0, 0, 0 ) surface.DrawOutlinedRect( 1, 1, w, h ) end end net.Receive( 'GroupMenu', function() OpenGroupMenu() end ) [/lua] Also, you may want to consider posting in this thread instead of making new threads. [url]http://facepunch.com/showthread.php?t=1411111[/url]
[code]function KillButt:DoClick()[/code] is incorrect, should be this - [code] KillButt.DoClick = function() -- what happens when you click the button end [/code] this is the same for all vgui buttons
[QUOTE=jack10685;45653568][code]function KillButt:DoClick()[/code] is incorrect, should be this - [code] KillButt.DoClick = function() -- what happens when you click the button end [/code] this is the same for all vgui buttons[/QUOTE] Both things are exactly the same, except first if providing self variable.
[QUOTE=jack10685;45653568][code]function KillButt:DoClick()[/code] is incorrect, should be this - [code] KillButt.DoClick = function() -- what happens when you click the button end [/code] this is the same for all vgui buttons[/QUOTE] doing the version you recommend give errors therefore i use what i currently use. it may work for you but it doesnt for me.
Sorry, you need to Log In to post a reply to this thread.