Garry's Mod Wiki

spawnmenu.AddContentType

  spawnmenu.AddContentType( string name, function constructor )

Description

Registers a new content type that is saveable into spawnlists. Created/called by spawnmenu.CreateContentIcon.

Arguments

1 string name
An unique name of the content type.
2 function constructor
A function that is called whenever we need create a new panel for this content type.
Function argument(s):
1 Panel container - The container/parent of the new panel from spawnmenu.CreateContentIcon
2 table data - Data for the content type passed from spawnmenu.CreateContentIcon.
Function return value(s):
1 Panel pnl - The created panel

Example

A simple header content type.

spawnmenu.AddContentType( "header", function( container, obj ) if ( !obj.text or type(obj.text) != "string" ) then return end local label = vgui.Create( "ContentHeader", container ) label:SetText( obj.text ) container:Add( label ) end )