derma.DefineControl

From Garry's Mod
Jump to: navigation, search
 derma.DefineControl( )

Contents

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

string name

Name of the newly created control

Arguments

string description

Description of the control

Arguments

table tab

Table containing control methods and properties

Arguments

string base

Derma control to base the new control off of

Returns

table

A table containing the new control's methods and properties

Examples

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")


Personal tools
Navigation