Garry's Mod Wiki

SANDBOX:PopulateContent

  SANDBOX:PopulateContent( panel pnlContent, panel tree, panel node )

Description

Called by the spawnmenu when the content tab is generated

Creating an error in this Hook will result in a completely broken Content Tab

Arguments

1 panel pnlContent
The SpawnmenuContentPanel
2 panel tree
The ContentNavBar tree from the SpawnmenuContentPanel
3 panel node
The old Spawnlists

Example

Generates an Example Category with a Models panel

hook.Add( "PopulateContent", "Example", function( pnlContent, tree, node ) local ViewPanel = vgui.Create( "ContentContainer", pnlContent ) ViewPanel:SetVisible( false ) ViewPanel.IconList:SetReadOnly( true ) ExampleNode = node:AddNode( "Example", "icon16/folder_database.png" ) ExampleNode.pnlContent = pnlContent ExampleNode.ViewPanel = ViewPanel local models = ExampleNode:AddNode( "Models", "icon16/exclamation.png" ) models.DoClick = function() ViewPanel:Clear( true ) local cp = spawnmenu.GetContentType( "model" ) if cp then for k, v in ipairs( file.Find( "models/*.mdl", "GAME" ) ) do cp( ViewPanel, { model = "models/" .. v } ) end end ExampleNode.pnlContent:SwitchPanel( ViewPanel ) end end)
Output: