Garry's Mod Wiki

vgui.RegisterTable

  table vgui.RegisterTable( table panel, string base = "Panel" )

Description

Registers a table to use as a panel, to be used with vgui.CreateFromTable.

All this function does is assigns Base key to your table and returns the table.

Arguments

1 table panel
The PANEL table.
2 string base = "Panel"
A base for the panel.

Returns

1 table
The PANEL table

Example

local CustomPanel = { Init = function( self ) self:SetSize( 200, 100 ) end, Paint = function( self, w, h ) surface.SetDrawColor( 0, 255, 0, 255 ) surface.DrawRect( 0, 0, w, h) end, } local my_custom_panel = vgui.RegisterTable( CustomPanel, "Panel" ) -- Register the panel class from a table local panel = vgui.CreateFromTable( my_custom_panel ) -- Create an instance of the panel panel:SetPos( 50, 50 )