Garry's Mod Wiki

ContentSidebar

Description

This is used internally - although you're able to use it you probably shouldn't.

The ContentSidebar is internally used by the spawnmenu and manages things like the Spawnmenu Toolbar. It internally uses a DTree which is accessible with ContentSidebar .Tree. When ContentSidebar:EnableModify has been called ContentSidebar.Toolbox will return a ContentSidebarToolbox

View source

Parent

Derives methods, etc not listed on this page from DPanel.

Implements

Implements or overrides the following hooks/methods. If you want to override these, you probably want to call the original function too.

Methods

ContentSidebar:CreateSaveNotification( string style, string hookname = "PopulateContent" )
Creates a Save Notification which will be shown when SANDBOX:SpawnlistContentChanged has been called.
ContentSidebar:EnableModify()
Internally calls ContentSidebar:EnableSearch, ContentSidebar:CreateSaveNotification and creates a ContentSidebarToolbox which is accessible under ContentSidebar. Toolbox. Call the Hook SANDBOX:OpenToolbox to open the created Toolbox
ContentSidebar:EnableSearch( string style, string hookname = "PopulateContent" )
Creates a search bar which will be displayed over the Nodes.

Example

How to create a ContentSidebar.

Frame = vgui.Create("DFrame") Frame:SetSize(ScrW() / 2, ScrH() / 2) Frame:Center() Frame:MakePopup() ContentSidebar = vgui.Create( "ContentSidebar", Frame) ContentSidebar:Dock(FILL) ContentSidebar:CreateSaveNotification() for k=1, 6 do local Node = ContentSidebar.Tree:AddNode("Example", "icon16/user.png") Node:SetHideExpander(true) Node:SetExpanded(true) Node.DoClick = function(self) hook.Call("SpawnlistContentChanged", GAMEMODE or GM) end for v=1, math.random(1, 5) do Node:AddNode("Example", "icon16/star.png") end end