Revision Difference
spawnmenu.AddToolMenuOption#518642
<function name="AddToolMenuOption" parent="spawnmenu" type="libraryfunc">
<description>Adds an option to the right side of the spawnmenu</description>
<realm>Client</realm>
<args>
<arg name="tab" type="string">The spawnmenu tab to add into (for example "Utilities")</arg>
<arg name="category" type="string">The category to add into (for example "Admin")</arg>
<arg name="tab" type="string">The spawnmenu tab to add into (for example "Utilities")</arg>
<arg name="category" type="string">The category to add into (for example "Admin")</arg>
<arg name="class" type="string">Unique identifier of option to add</arg>
<arg name="name" type="string">The nice name of item</arg>
<arg name="cmd" type="string">Command to execute when the item is selected</arg>
<arg name="config" type="string">Config name, used in older versions to load tool settings UI from a file. No longer works.

<deprecated>Category=No</deprecated></arg>⤶
<arg name="cpanel" type="function">A function to build the context panel. The function has one argument:
* <page>Panel</page> pnl - A <page>DForm that will be shown in the context menu</page></arg>⤶
<arg name="config" type="string">Config name, used in older versions to load tool settings UI from a file. No longer works.⤶
⤶
<deprecated>Category=No</deprecated></arg>⤶
<arg name="cpanel" type="function">A function to build the context panel. The function has one argument:⤶
* <page>Panel</page> pnl - A <page>DForm that will be shown in the context menu</page></arg>⤶
<arg name="table" type="table" default="{}">Allows to override the table that will be added to the tool list. Some of the fields will be overwritten by this function.</arg>
</args>
</function>
<example>
<description>Adds a new option to the menu with a slider to change the gravity</description>
<code>
hook.Add( "AddToolMenuCategories", "CustomCategory", function()
spawnmenu.AddToolCategory( "Utilities", "Stuff", "#Stuff" )
end )
hook.Add( "PopulateToolMenu", "CustomMenuSettings", function()
spawnmenu.AddToolMenuOption( "Utilities", "Stuff", "Custom_Menu", "#My Custom Menu", "", "", function( panel )
panel:ClearControls()
panel:NumSlider( "Gravity", "sv_gravity", 0, 600 )
-- Add stuff here
end )
end )
</code>
<output><image src="addtoolmenuoption.png" alt="400px"/></output>
</example>