Remarks
This control display a hierarchy of nodes that can be expanded and collapsed. This base control does not automatically expand or collapse nodes. It is the responsibility of the scripter to invoke the SetExpanded method on the nodes in response to user input.
Examples
This example demonstrates creating a tree view control and populating it with nodes.
Using a TreeView | ![]() |
---|---|
-- Define a tree node class to put into the tree. MyTreeNode = class( Turbine.UI.TreeNode ); function MyTreeNode:Constructor() Turbine.UI.TreeNode.Constructor( self ); self:SetBackColor( Turbine.UI.Color( math.random(), math.random(), math.random() ) ); self:SetSize( 100, 18 ); end -- Create the container window. window = Turbine.UI.Lotro.Window(); window:SetSize( 400, 400 ); window:SetPosition( 100, 100 ); window:SetText( "Treeview test" ); window:SetVisible( true ); -- Create the tree view control. treeView = Turbine.UI.TreeView(); treeView:SetParent( window ); treeView:SetPosition( 10, 50 ); treeView:SetSize( 300, 200 ); treeView:SetBackColor( Turbine.UI.Color( 0.2, 0.2, 0.2 ) ); treeView:SetIndentationWidth( 15 ); -- Give the tree view a scroll bar. scriptTextScrollBar = Turbine.UI.Lotro.ScrollBar(); scriptTextScrollBar:SetOrientation( Turbine.UI.Orientation.Vertical ); scriptTextScrollBar:SetParent( window ); scriptTextScrollBar:SetPosition( 300, 50 ); scriptTextScrollBar:SetSize( 10, 200 ); treeView:SetVerticalScrollBar( scriptTextScrollBar ); -- Populate the test nodes. rootNodes = treeView:GetNodes(); local i; local j; for i = 1, 5 do local node = MyTreeNode(); rootNodes:Add( node ); local subNodes = node:GetChildNodes(); for j = 1, 5 do local node = MyTreeNode(); subNodes:Add( node ); local subNodes = node:GetChildNodes(); for k = 1, 5 do local node = MyTreeNode(); subNodes:Add( node ); local subNodes = node:GetChildNodes(); for l = 1, 5 do local node = MyTreeNode(); subNodes:Add( node ); end end end end |