Garry's Mod Wiki


  Panel Panel:Add( Panel object )


Adds the specified object to the panel.


1 Panel object
The panel to be added (parented). Can also be:
  • string Class Name - creates panel with the specified name and adds it to the panel.
  • table PANEL table - creates a panel from table and adds it to the panel.


1 Panel
New panel


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