Garry's Mod Wiki

DTree

Description

A tree view element for Derma.

See also DTree_Node.

View source

Parent

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

Events

DTree:ChildExpanded( boolean bExpand )
This is used internally - although you're able to use it you probably shouldn't. Calls directly to Panel:InvalidateLayout. Called by DTree_Nodes when a sub element has been expanded or collapsed. Used as a placeholder function alongside DTree:ExpandTo, DTree:SetExpanded and DTree:MoveChildTo. The DTree acts a root node and methods with the same name in DTree_Node call to the parent.
boolean DTree:DoClick( DTree_Node node )
Called when the any node is clicked. Called by DTree_Node:DoClick.
Called when the any node is right clicked. Called by DTree_Node:DoRightClick.
DTree:OnNodeSelected( Panel node )
This function is called when a node within a tree is selected.

Methods

Panel DTree:AddNode( string name, string icon = "icon16/folder.png" )
Add a node to the DTree
DTree:ExpandTo( boolean bExpand )
This is used internally - although you're able to use it you probably shouldn't. Does nothing. Used as a placeholder empty function alongside DTree:MoveChildTo, DTree:SetExpanded and DTree:ChildExpanded. The DTree acts a root node and methods with the same name in DTree_Node call to the parent.
Returns the status of DTree:SetClickOnDragHover. See that for more info.
Returns the indentation size of the DTree, the distance between each "level" of the tree is offset on the left from the previous level. Currently this feature has no effect on the DTree element.
Returns the height of each DTree_Node in the tree.
Returns the currently selected node.
Returns whether or not the Silkicons next to each node of the DTree will be displayed. Individual icons can be set with DTree_Node:SetIcon or passed as the second argument in DTree:AddNode.
DTree:LayoutTree()
We advise against using this. It may be changed or removed in a future update. Does nothing.
DTree:MoveChildTo( Panel child, number pos )
Moves given node to the top of DTrees children. (Makes it the topmost mode) Used as a placeholder function alongside DTree:ExpandTo, DTree:SetExpanded and DTree:ChildExpanded. The DTree acts a root node and methods with the same name in DTree_Node call to the parent.
Panel DTree:Root()
Returns the root DTree_Node, the node that is the parent to all other nodes of the DTree.
DTree:SetClickOnDragHover( boolean enable )
Enables the "click when drag-hovering" functionality. If enabled, when hovering over any DTree_Node of this DTree while dragging a panel, the node will be automatically clicked on (and subsequently DTree:OnNodeSelected will be called) to open any attached panels, such as spawnlists in spawnmenu. See also: PANEL:DragHoverClick.
DTree:SetExpanded( boolean bExpand )
This is used internally - although you're able to use it you probably shouldn't. Does nothing. Is not called by the DTree itself. Used as a placeholder empty function alongside DTree:ExpandTo, DTree:MoveChildTo and DTree:ChildExpanded to prevent errors when DTree_Node:SetExpanded is incorrectly used on a DTree.
DTree:SetIndentSize( number size )
Sets the indentation size of the DTree, the distance between each "level" of the tree is offset on the left from the previous level. Currently this feature has no effect on the DTree element.
DTree:SetLineHeight( number h )
Sets the height of each DTree_Node in the tree. The default value is 17.
DTree:SetSelectedItem( Panel node )
Set the currently selected top-level node.
DTree:SetShowIcons( boolean show )
Sets whether or not the Silkicons next to each node of the DTree will be displayed. Individual icons can be set with DTree_Node:SetIcon or passed as the second argument in DTree:AddNode.
Returns whether or not the Silkicons next to each node of the DTree will be displayed. Alias of DTree:GetShowIcons.

Example

Example of using DTree

local frame = vgui.Create( "DFrame" ) frame:SetSize( 300, 500 ) frame:Center() frame:MakePopup() local dtree = vgui.Create( "DTree", frame ) dtree:Dock( FILL ) local node = dtree:AddNode( "Node One" ) local node = dtree:AddNode( "Node Two" ) local cnode = node:AddNode( "Node 2.1" ) local cnode = node:AddNode( "Node 2.2" ) local cnode = node:AddNode( "Node 2.3" ) local cnode = node:AddNode( "Node 2.4" ) local cnode = node:AddNode( "Node 2.5" ) local gcnode = cnode:AddNode( "Node 2.5" ) local cnode = node:AddNode( "Node 2.6" ) local node = dtree:AddNode( "Node Three ( Maps Folder )" ) node:MakeFolder( "maps", "GAME", true ) local node = dtree:AddNode( "Node Four" )
gmod_kBGJMEHMBn.gif