Garry's Mod Wiki

Panel:Add

  Panel Panel:Add( Panel object )
  Panel Panel:Add( string class )
  Panel Panel:Add( table table )

Description

Adds the specified object to the panel.

Default Arguments

1 Panel object
The panel to be added (parented).

Argument Overload: Class Name

1 string class
The class to be added.

Argument Overload: Panel Table

1 table table
The table to create the panel from.

Returns

1 Panel
New panel

Example

Create a Panel with vgui.Register, and initialize a DScrollPanel with Panel:Add

local PANEL = {} function PANEL:Init() -- Guarantees only one instance of the frame is open at a time. if IsValid(SingleDFrame) then SingleDFrame:Remove() end local sw = ScrW() local sh = ScrH() self:SetSize(sw * 0.25, sh * 0.5) self:SetTitle("Window (Scroll)") self:Center() self:MakePopup() self.Canvas = self:Add("DScrollPanel") self.Canvas:Dock(FILL) end vgui.Register("DFrameScrollable", PANEL, "DFrame") SingleDFrame = vgui.Create("DFrameScrollable")