Garry's Mod Wiki

derma.DefineControl

  table derma.DefineControl( string name, string description, table tab, string base )

Description

Defines a new Derma control with an optional base.

This calls vgui.Register internally, but also does the following:

  • Adds the control to derma.GetControlList
  • Adds a key "Derma" - This is returned by derma.GetControlList
  • Makes a global table with the name of the control (This is technically deprecated and should not be relied upon)
  • If reloading (i.e. called this function with name of an existing panel), updates all existing instances of panels with this name. (Updates functions, calls PANEL:PreAutoRefresh and PANEL:PostAutoRefresh, etc.)

Arguments

1 string name
Name of the newly created control
2 string description
Description of the control
3 table tab
Table containing control methods and properties
4 string base
Derma control to base the new control off of

Returns

1 table
A table containing the new control's methods and properties

Example

Defines a new control based off of DTextEntry that prints to the console whenever it is changed

local PANEL = {} function PANEL:OnChange() print(self:GetValue()) end derma.DefineControl("MyTextEntry", "Printing text entry control", PANEL, "DTextEntry")