Garry's Mod Wiki

Revision Difference

ControlPanel:AddControl#517135

<function name="AddControl" parent="ControlPanel" type="panelfunc"> <ispanel>yes</ispanel> <description> <deprecated>It is recommended to use <page>DForm</deprecated>'s members instead.</page>⤶ <deprecated>It is recommended to use <page>DForm</page>'s members instead.</deprecated>⤶ Adds a control to the control panel. </description> <file line="119-L397">gamemodes/sandbox/gamemode/spawnmenu/controlpanel.lua</file> <realm>Client</realm> <args> <arg name="type" type="string">The control type to add. The complete list is:&#xA;* header&#xA;* textbox&#xA;* label&#xA;* checkbox/toggle&#xA;* slider&#xA;* propselect&#xA;* matselect&#xA;* ropematerial&#xA;* button&#xA;* numpad&#xA;* color&#xA;* combobox&#xA;* listbox&#xA;* materialgallery</arg> <arg name="controlinfo" type="table">Each control takes their own table structure. You may search &quot;AddControl&quot; on GitHub for examples.&#xA;&#xA;Here is a full list of each type and the table members it requires:&#xA;&#xA;* header&#xA;* *description&#xA;&#xA;* textbox:&#xA;* *label (def: &quot;Untitled&quot;)&#xA;* *command&#xA;&#xA;* label:&#xA;* *text&#xA;&#xA;* checkbox, toggle (same thing):&#xA;* *label (def: &quot;Untitled&quot;)&#xA;* *command&#xA;* *help (boolean, if true assumes label is a language string (&quot;#tool.toolname.stuff&quot;) and adds &quot;.help&quot; at the end)&#xA;&#xA;* slider:&#xA;* *type (optional string, if equals &quot;float&quot; then 2 digits after the decimal will be used, otherwise 0)&#xA;* *label (def: &quot;Untitled&quot;)&#xA;* *command&#xA;* *min (def: 0)&#xA;* *max (def: 100)&#xA;* help (boolean, see above)&#xA;&#xA;* propselect:&#xA;* *(data goes directly to PropSelect&#x27;s :ControlValues(data))&#xA;&#xA;* matselect:&#xA;* *(data goes directly to MatSelect&#x27;s :ControlValues(data))&#xA;&#xA;* ropematerial:&#xA;* *convar (notice: NOT called command this time!)&#xA;&#xA;* button:&#xA;* *label / text (if label is missing will use text. Def: &quot;No Label&quot;)&#xA;* *command&#xA;&#xA;* numpad:&#xA;* *command&#xA;* *command2&#xA;* *label&#xA;* *label2&#xA;&#xA;* color:&#xA;* *label&#xA;* *red (convar)&#xA;* *green (convar)&#xA;* *blue (convar)&#xA;* *alpha (convar)&#xA;&#xA;* combobox:&#xA;* *menubutton (if doesn&#x27;t equal &quot;1&quot;, becomes a listbox)&#xA;* *folder&#xA;* *options (optional, ha)&#xA;* *cvars (optional)&#xA;&#xA;* listbox:&#xA;* *height (if set, becomes &lt;page&gt;DListView&lt;/page&gt;, otherwise is &lt;page&gt;CtrlListBox&lt;/page&gt;)&#xA;* *label (def: &quot;unknown&quot;)&#xA;* *options (optional)&#xA;&#xA;* materialgallery:&#xA;* *width (def: 32)&#xA;* *height (def: 32)&#xA;* *rows (def: 4)&#xA;* *convar&#xA;* *options</arg> </args> </function>