TreeΒΆ

class Tree

A simple tree list

This class implements basic behaviour for a tree organized list. It is possible to specialize some part of the tree behaviour to enrich the tree list window. By default, a Tree uses a simple tree of nested table, where children are stored in the array part. Each child might be a string or a table. If a child is a table, then Name must be filled with the child name.

local tree = ui.tree ("tree", parent)
tree:settree ( {
    "leafA",
    "leafB",
    "leafC",
    { Name = "Node1",
        "leafAA",
        { Name = "Node2",
            "leafAAA",
            "leafBBB",
            "leafCCC",
        },
        "leafBB",
    }
} )        

Hierarchy

class Tree < class Window

Members

Methods:

boolean expandable canexpanditem ( ?? item ) Override This method must return true if the item can be expanded, to display the expand button
boolean selectable canselectitem ( ?? item ) Override This method must return true if the item can be selected
ui.color color getitemcolor ( ?? item ) Override This method must return the text color for this item
number count getitemcount ( ?? item ) Override This method must return the number of children item within a tree node.
string|nil icon getitemicon ( ?? item ) Override This method must return the icon texture for this item, or nil if no icon is needed
string text getitemtext ( ?? item ) Override This method must return the text for this item
?? selection getselection ( ) Return the selected item
nil selectionchanged ( table selection ) Override This method is called when the tree list selection has changed
nil setselection ( ?? item ) Set the current selection
nil setttree ( table tree ) Update the tree list with the new given tree


Inherited from class Window

Methods:

nil destroy ( ) Destroy the window and all its children windows
nil setx ( number x , number parentpivot , number pivot ) Set the X window placement
nil sety ( number y , number parentpivot , number pivot ) Set the Y window placement
nil setw ( number w , number parentmul , number childadd , number childmul ) Set the window width
nil seth ( number h , number parentmul , number childadd , number childmul ) Set the window height
nil getx ( ) Get the window X coordinate in the parent space
nil gety ( ) Get the window Y coordinate in the parent space
nil getw ( ) Get the window width
nil geth ( ) Get the window height
nil hide ( ) Hide the window
nil show ( ) Show the window
nil disable ( ) Disable the window
nil enable ( ) Enable the window
string path getnodepath ( ) Returns the edited node path (is nil if the method is not supported)
nil setnodepath ( string path )
nil addtracker ( table tracker ) Add a tracker to this window. A tracker receives notification when the tracked window is invalidated or destroyed. A tracker may implement onTrackedDestroyed and onTrackedInvalidated to get notifications on such events
nil removetracker ( table tracker ) Remove a tracker of this window.
nil setcolor ( ui.color color ) Change the window color, see also ui.color function
nil getparent ( string|nil parentclass ) Get the first parent window of given class (immediate parent if no class is provided)
nil settopmost ( ) Set the window as top most in children order
nil getchild ( string|number name ) Get a child window
Window container getcontainer ( ) Get the main container of a window
nil settitle ( string name ) Change the window title
nil setfocus ( ) Set the focus to the window
nil getroot ( ) Return the root window of this window

Documentation

boolean expandable canexpanditem ( ?? item )

Override This method must return true if the item can be expanded, to display the expand button

Arguments:

  • item The tree item to query

Return:

  • expandable True iff item can be expanded


boolean selectable canselectitem ( ?? item )

Override This method must return true if the item can be selected

Arguments:

  • item The tree item to query

Return:

  • selectable True iff item can be selected


ui.color color getitemcolor ( ?? item )

Override This method must return the text color for this item

Arguments:

  • item The tree item to query

Return:

  • color The item displayed color


number count getitemcount ( ?? item )

Override This method must return the number of children item within a tree node.

Arguments:

  • item The tree item to query

Return:

  • count The number of children in the item


string|nil icon getitemicon ( ?? item )

Override This method must return the icon texture for this item, or nil if no icon is needed

Arguments:

  • item The tree item to query

Return:

  • icon The icon name, or nil for no icon


string text getitemtext ( ?? item )

Override This method must return the text for this item

Arguments:

  • item The tree item to query

Return:

  • text The item displayed name


?? selection getselection ( )

Return the selected item

Return:

  • selection The selected item


nil selectionchanged ( table selection )

Override This method is called when the tree list selection has changed

Arguments:

  • selection The new selection


nil setselection ( ?? item )

Set the current selection

Arguments:

  • item The new selected item


nil setttree ( table tree )

Update the tree list with the new given tree

Arguments:

  • tree The tree to be displayed