Garry's Mod Wiki

DMenu:AddPanel

DMenu:AddPanel( Panel pnl )

Description

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

1 Panel pnl
The panel that you want to add.

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:

Page Links


Special Pages


Wikis

?

Render Time: 37ms

DB GetPage 3
Generate Html 10
SaveChanges (1) 9
Render Body 0
Render Sidebar 12