DMenu/AddPanel

From Garry's Mod
Jump to: navigation, search
 DMenu:AddPanel( )

Contents

DescriptionPanelFunc

Adds a panel to the DMenu as if it were an option.

This invokes DScrollPanel:AddItem and will not create a new panel if a class name is passed, unlike Panel:Add.

Arguments

Panel pnl

The panel that you want to add.

Examples

Example

Creates a DMenu with some options and places a red DPanel between them.

local m = DermaMenu()

m:AddOption( "Kill yourself", function() RunConsoleCommand( "kill" ) end ) -- Add first option
m:AddSpacer()

-- Create a red DPanel
local panel = vgui.Create( "DPanel", m )
panel:SetSize( 50, 100 )
panel:SetBackgroundColor( Color( 255, 0, 0 ) )

m:AddPanel( panel ) -- Add the panel

m:AddSpacer()
m:AddOption( "Say hi", function() RunConsoleCommand( "say", "Hi!" ) end ) -- Add second option

m:Open() -- Show our menu

Output:



DMenu AddPanel eg.png
Personal tools
Navigation