spawnmenu.AddContentType

From Garry's Mod
Jump to: navigation, search
 spawnmenu.AddContentType( )

Contents

Description

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

Arguments

string name

An unique name of the content type.

Arguments

function constructor

A function that is called whenever we need create a new panel for this content type.

It has two arguments:
Panel container - The container/parent of the new panel
table data - Data for the content type passed from spawnmenu.CreateContentIcon


Examples

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 )


Personal tools
Navigation