Revision Difference
spawnmenu.AddContentType#512889
<function name="AddContentType" parent="spawnmenu" type="libraryfunc">⤶
<description>⤶
Registers a new content type that is saveable into spawnlists.⤶
Created/called by <page>spawnmenu.CreateContentIcon</page>.⤶
</description>⤶
<realm>Client</realm>⤶
<args>⤶
<arg name="name" type="string">An unique name of the content type.</arg>⤶
<arg name="constructor" type="function">A function that is called whenever we need create a new panel for this content type.

It has two arguments:


<page>Panel</page> container - The container/parent of the new panel


<page>table</page> data - Data for the content type passed from <page>spawnmenu.CreateContentIcon</page></arg>⤶
</args>⤶
</function>⤶
⤶
<example>⤶
<description>A simple header content type.</description>⤶
<code>⤶
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 )⤶
</code>⤶
⤶
</example>