Garry's Mod Wiki

Revision Difference

spawnmenu.AddContentType#518055

<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.&#xA;&#xA;It has two arguments:&#xA;&#xA;&#xA;&lt;page&gt;Panel&lt;/page&gt; container - The container/parent of the new panel&#xA;&#xA;&#xA;&lt;page&gt;table&lt;/page&gt; data - Data for the content type passed from &lt;page&gt;spawnmenu.CreateContentIcon&lt;/page&gt;</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>