Garry's Mod Wiki

vgui.Register

  table vgui.Register( string classname, table panelTable, string baseName = "Panel" )

Description

Registers a panel for later creation via vgui.Create.

Arguments

1 string classname
Classname of the panel to register. This is what you will need to pass to vgui.Create's first argument.
2 table panelTable
The table containing the panel information.
3 string baseName = "Panel"
Classname of a panel to inherit functionality from. Functions with same names will be overwritten preferring the panel that is being registered.

Returns

1 table
The given panel table from second argument

Example

Defines a Panel named PanelName that derives from DButton

local PANEL = {} PANEL.ColorIdle = Color(255, 0, 0) PANEL.ColorHovered = Color(0, 255, 0) function PANEL:Paint(w, h) local color = self.ColorIdle if self:IsHovered() then color = self.ColorHovered end surface.SetDrawColor(color) surface.DrawRect(0, 0, w, h) end vgui.Register("PanelName", PANEL, "DButton")