Revision Difference
vgui.Register#546682
<function name="Register" parent="vgui" type="libraryfunc">
<description>Registers a panel for later creation.</description>
<realm>Client and Menu</realm>
<file line="71-95">lua/includes/extensions/client/panel/scriptedpanels.lua</file>
<args>
<arg name="classname" type="string">Classname of the panel to create.</arg>
<arg name="panelTable" type="table">The table containg the panel information.</arg>
<arg name="baseName" type="string" default="Panel">Name of the base of the panel.</arg>
</args>
<rets>
<ret name="" type="table">The given panel table from second argument</ret>
</rets>
</function>
⤶
⤶
<example>⤶
<description>Defines a Panel named `PanelName` that derives from `DButton`</description>⤶
<code>⤶
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")⤶
⤶
</code>⤶
</example>