Garry's Mod Wiki

Revision Difference

ControlPanel:AddControl#518590

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