Back

addTreeView

JS Py
Hello World
Content:
- Examples
- Properties
- Methods

A TreeView is a hierarchical representation of data, often used to display nested categories or organized information.*

var items = {
"Group 1": {
"Item 1": "",
"Item 2": "",
"Item 3": ""

},
"Group 2": {
"Item 1": "",
"Item 2": "",
"Item 3": ""

},
"Applications": {
"Editor": "",
"Productivity": "",
"Social Media": {
"TikTok": "",
"YouTube": "",
"Meta": {
"Facebook": "",
"Instagram": "",
"Whatsapp": "",
"Messenger": ""
}
}

}

}

`var items = {"Group 1": {"Item 1": "","Item 2": "","Item 3": ""},"Group 2": {"Item 1": "","Item 2": "","Item 3": ""},"Applications": {"Editor": "","Productivity": "","Social Media": {"TikTok": "","YouTube": "","Meta": {"Facebook": "","Instagram": "","Whatsapp": "","Messenger": ""}}}}`


The properties of the list object will be the name of the item or the group.

trv = ui.addTreeView( parent, list?, options?, width?, height? ) → ui object: TreeView

If you add a string value to the list object properties, it will be treated as an icon.
See example below

#Example - Items with iconsvar items = {"Folders": {"Music": "music_note","Photos": "photo","Favorites": "favorite"}}

Here are the available methods of the TreeView Component.

Examples

Example - Basic TreeView

class Main extends App
{
    onStart()
    {
        // Create a fullscreen layout with objects vertically centered
        this.main = ui.addLayout("main", "Linear", "Center,ScrollY,FillXY")

        // Initialize json object for the treeview items
        var items = {
            "Group 1": {
                "Item 1": "",
                "Item 2": "",
                "Item 3": ""
            },
            "Group 2": {
                "Item 1": "",
                "Item 2": "",
                "Item 3": ""
            },
            "Applications": {
                "Editor": "",
                "Productivity": "",
                "Social Media": {
                    "TikTok": "",
                    "YouTube": "",
                    "Meta": {
                        "Facebook": "",
                        "Instagram": "",
                        "Whatsapp": "",
                        "Messenger": ""
                    }
                }
            }
        }

        // Add a treeview component to the main layout
        this.trv = ui.addTreeView(this.main, items, "Primary")
        this.trv.setMargins(0, 5, 0, 0, "rem")

        // Add a callback handler when the treeview item is touched
        this.trv.setOnTouch( this.onTouch )
    }

    onTouch(value, path)
    {
        ui.showPopup("Value: "+value + " Path: "+path)
    }
}
from hybrid import ui

def OnStart():
    main = ui.addLayout("main", "Linear", "Center,ScrollY,FillXY")

    items = {
        "Group 1": {
            "Item 1": "",
            "Item 2": "",
            "Item 3": ""
        },
        "Group 2": {
            "Item 1": "",
            "Item 2": "",
            "Item 3": ""
        },
        "Applications": {
            "Editor": "",
            "Productivity": "",
            "Social Media": {
                "TikTok": "",
                "YouTube": "",
                "Meta": {
                    "Facebook": "",
                    "Instagram": "",
                    "Whatsapp": "",
                    "Messenger": ""
                }
            }
        }
    }

    trv = ui.addTreeView(main, items, "Primary")
    trv.setMargins(0, 5, 0, 0, "rem")
    trv.setOnTouch(onTouch)

def onTouch(value, path):
    ui.showPopup("Value: " + value + " Path: " + path)
Copy All       Run      

Properties

The following properties are available on the TreeView object:

absHeightNumber
absLeftNumber
absTopNumber
absWidthNumber
backColorString
backImageString
borderNumber
borderColorString
borderStyleString
cornerRadiusNumber
disabledBoolean
elObject
elStyleString
fontFileString
heightNumber
isVisibleBoolean
leftNumber
listObject
marginsList
opacityNumber
optionsString
paddingList
parentObject
positionObject
rotationNumber
textColorString
textSizeNumber
topNumber
typeString
valueString
visibilityString
widthNumber

Methods

The following methods are available on the TreeView object:

getItem( name ) → Object
getPosition( options ) → Object
gone()
hide()
setScale( x, y )
show()
Number: Fraction of the parent width `[0-1]`.
Number: Fraction of the parent height `[0-1]`.
Number: The time in milliseconds.
Number: The z-index. A negative value behaves like `sendBackward` method.
Number: The z-index. A positve value behaves like `bringForward` method.
Number: Border-left thickness in pixels.
Number: Border-top thickness in pixels.
Number: Border-right thickness in pixels.
Number: Border-bottom thickness in pixels.
Number: Top-Left border radius.
Number: Top-Right border radius.
Number: Bottom-Right border radius.
Number: Bottom-Left border radius.
Number: Left margin. You can also pass string e.g. `12rem`
Number: Top margin. You can also pass string e.g. `12rem`
Number: Right margin. You can also pass string e.g. `12rem`
Number: Bottom margin. You can also pass string e.g. `12rem`
Number: Fraction of the component width.
Number: Fraction of the component height. [0-1]
Number: Fraction of the component width. [0-1]
Number: Fraction of the parent width. [0-1]
Number: Fraction of the parent height. [0-1]
Number: The x-scale of the component.Values less than `0` is smaller than the normal. While values greater than `1` is greater than the normal.
Number: The y-scale of the component. Values less than `1` is smaller than the normal. While vaues greater than `1` is greater than the normal.
String: “A comma separated options. Values can be `MultiSelect`.”
String: “The label text for the new item.”
String: “The type of animation. Here are the available values
`bounce`”
, “ `flash`”, “ `pulse`”, “ `rubberBand`”, “ `shakeX`”, “ `shakeY`”, “ `headShake`”, “ `swing`”, “ `tada`”, “ `wobble`”, “ `jello`”, “ `heartBeat`”,
Back Entrances: `backInDown`”
, “ `backInLeft`”, “ `backInRight`”, “ `backInUp`
Back Exits: `backOutDown`”
, “ `backOutLeft`”, “ `backOutRight`”, “ `backOutUp`
Bouncing Entrances: `bounceIn`”
, “ `bounceInDown`”, “ `bounceInLeft`”, “ `bounceInRight`”, “ `bounceInUp`
Bouncing exits: `bounceOut`”
, “ `bounceOutDown`”, “ `bounceOutLeft`”, “ `bounceOutRight`”, “ `bounceOutUp`
Fading entrances: `fadeIn`”
, “ `fadeInDown`”, “ `fadeInDownBig`”, “ `fadeInLeft`”, “ `fadeInLeftBig`”, “ `fadeInRight`”, “ `fadeInRightBig`”, “ `fadeInUp`”, “ `fadeInUpBig`”, “ `fadeInTopLeft`”, “ `fadeInTopRight`”, “ `fadeInBottomLeft`”, “ `fadeInBottomRight`
Fading exits: `fadeOut`”
, “ `fadeOutDown`”, “ `fadeOutDownBig`”, “ `fadeOutLeft`”, “ `fadeOutLeftBig`”, “ `fadeOutRight`”, “ `fadeOutRightBig`”, “ `fadeOutUp`”, “ `fadeOutUpBig`”, “ `fadeOutTopLeft`”, “ `fadeOutTopRight`”, “ `fadeOutBottomRight`”, “ `fadeOutBottomLeft`
Flippers: `flip`”
, “ `flipInX`”, “ `flipInY`”, “ `flipOutX`”, “ `flipOutY`
Lightspeed: `lightSpeedInRight`”
, “ `lightSpeedInLeft`”, “ `lightSpeedOutRight`”, “ `lightSpeedOutLeft`
Rotating Entrances: `rotateIn`”
, “ `rotateInDownLeft`”, “ `rotateInDownRight`”, “ `rotateInUpLeft`”, “ `rotateInUpRight`
Rotating Exits: `rotateOut`”
, “ `rotateOutDownLeft`”, “ `rotateOutDownRight`”, “ `rotateOutUpLeft`”, “ `rotateOutUpRight`
Specials: `hinge`”
, “ `jackInTheBox`”, “ `rollIn`”, “ `rollOut`
Zooming Entrances: `zoomIn`”
, “ `zoomInDown`”, “ `zoomInLeft`”, “ `zoomInRight`”, “ `zoomInUp`
Zooming Exits: `zoomOut`”
, “ `zoomOutDown`”, “ `zoomOutLeft`”, “ `zoomOutRight`”, “ `zoomOutUp`
Sliding Entrances: `slideInDown`”
, “ `slideInLeft`”, “ `slideInRight`”, “ `slideInUp`
Sliding Exits: `slideOutDown`”
, “ `slideOutLeft`”, “ `slideOutRight`”, “ `slideOutUp`”
String: “The parent name of the tree items.”
String: “The mode of the measurements. Values can be `px` or `%`”
String: “Border color in hexadecimal format `#rrggbb`.”
String: “Border-styles. Values can be `dotted`”, “ `dashed`”, “ `solid`”, “ `double`”, “ `groove`”, “ `ridge`”, “ `inset` and `outset`. Default is `solid`”
String: “Unit of measurement. Values are `px` `rem` or `%`.”
String: “Unit of measurement.
`rem` for root em.
`px` for pixels
`%` relative to its parent dimension.
`v` relative to viewport dimension.”
String: “Unit of measurement.
`rem` for root em.
`px` for pixels
`%` relative to its parent dimensions
`v` relative to viewport dimensions.”
String: “Unit of measurment. Can be "px"”, “ "rem"”, “ "%"”, “ "v" for viewport width/height or any css supported unit.”
Object: The parent layout where to add the TreeView component.
Object: An object of the treeview items. See example below.
Object: See list object for more info.
Object: The list object of the treeview items. See example above.
Object: The pointer event object.
function( event )
function( value , path )
trv.absHeight
Returns the absolute height of the control in pixels.
trv.absLeft
Returns the absolute distance of the control from the left in pixels.
trv.absTop
Returns the absolute distance of the control from the top in pixels.
trv.absWidth
Returns the absolute width of the control in pixels.
trv.addItem
Add a tree items to the tree view.
trv.animate
Animate the component.
trv.backColor
A hexadecimal color of the form #rrggbb
trv.backImage
The path to your image file.
trv.border
Sets or returns the border thickness in pixels.
trv.borderColor
Sets or returns the border color. Color is in hexadecimal form #rrggbb
trv.borderStyle
Sets or returns the border style. Values can be dotted, dashed, solid, double, groove, ridge, inset and outset. Default is solid.
trv.bringForward
Bring this component forward by a given z-index.
trv.cornerRadius
Sets or returns the corner radius in pixels.
trv.destroy
Destroy the component.
trv.disabled
Sets or returns the disabled state of the control.
trv.el
Returns the html container element for the control.
trv.elStyle
Sets the style of the html container element.
trv.fontFile
Sets or returns the relative path to the font-family use.
trv.getItem
Returns the list items object of a given parent tree item name.
trv.getPosition
Returns the position of the component. The return object is of the form {left, top, right, bottom}
trv.gone
Destroy the component.
trv.height
Sets or returns the height of the control as a fraction of the parent control.
trv.hide
Hide the component.
trv.isVisible
Returns whether the control is visible or not.
trv.left
Returns the distance of the control from the left.
trv.list
Sets or returns the list object.
trv.margins
Sets or returns the margin of the control. Works on controls with Linear parent only. You can also pass a number to set equal margins for all sides.
trv.opacity
Sets or returns the opacity of the control.
trv.options
Sets or returns the options of the control.
trv.padding
Sets or returns the padding of the control. You can also pass a number to set equal padding for all sides.
trv.parent
Returns the parent layout control.
trv.position
Returns the position of the control. The returned object has left top right and bottom props.
trv.rotation
Sets or returns the angle of rotation in degrees.
trv.sendBackward
Bring this component backward by a given z-index.
trv.setBorder
Sets the border line for the component container.
trv.setCornerRadius
Sets the corner radius of the component.
trv.setList
Updates the list items of the TreeView component.
trv.setMargins
Sets the margin of the component.
trv.setOnContextMenu
Adds a callback function on right click.
trv.setOnTouch
Add a on touch handler to the TreeView item when click.
trv.setPadding
Sets the padding of the component's container.
trv.setPosition
Sets the position of the component relative to its parent dimensions.
trv.setScale
Sets the x and y scaling of the component. This will ignore the positioning and flow of controls in the layout.
trv.setSize
Sets the size of the component.
trv.show
Show the component.
trv.textColor
Sets or returns the color of the text.
trv.textSize
Sets or returns the size of the text within the control.
trv.top
Returns the distance of the control from the top.
trv.type
Returns the type of the control.
trv.value
Returns the selected item of the TreeView.
trv.visibility
Sets or returns the visibility of the control.
trv.width
Sets or returns the width of the control as a fraction of the parent control.