PANEL:GenerateExample

From Garry's Mod
Jump to: navigation, search
 PANEL:GenerateExample( )

Contents

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.

Arguments

string class

The classname of the panel to generate example for. This will be the class name of your panel.

Arguments

Panel dpropertysheet

A DPropertySheet to add your example to. See examples below.

Arguments

number width

Width of the property sheet?

Arguments

number height

Width of the property sheet?

Examples

Example

Example usage of this hook from DButton's 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" )

Output:

A tab named "DButton" will appear in derma_controls menu.
Personal tools
Navigation