Garry's Mod Wiki

Revision Difference

PANEL:GenerateExample#517670

<function name="GenerateExample" parent="PANEL" type="hook"> <ishook>yes</ishook> <description>Called when the panel should generate example use case / example code to use for this panel. Used in the panel opened by **derma_controls** console command.</description> <realm>Client</realm> <predicted>No</predicted> <hidepredictionwarning>No</hidepredictionwarning> <args> <arg name="class" type="string">The classname of the panel to generate example for. This will be the class name of your panel.</arg> <arg name="dpropertysheet" type="Panel">A &lt;page&gt;DPropertySheet&lt;/page&gt; to add your example to. See examples below.</arg> <arg name="dpropertysheet" type="Panel">A <page>DPropertySheet</page> to add your example to. See examples below.</arg> <arg name="width" type="number">Width of the property sheet?</arg> <arg name="height" type="number">Width of the property sheet?</arg> </args> </function> <example> <description>Example usage of this hook from DButton's code.</description> <code> function PANEL:GenerateExample( ClassName, PropertySheet, Width, Height ) local ctrl = vgui.Create( ClassName ) ctrl:SetText( "Example Button" ) ctrl:SetWide( 200 ) PropertySheet:AddSheet( ClassName, ctrl, nil, true, true ) end derma.DefineControl( "DButton", "A standard Button", PANEL, "DLabel" ) </code> <output>A tab named "DButton" will appear in **derma_controls** menu.</output> </example>