B4J Library [B4X] [XUI] SD_TreeList

Star-Dust

Expert
Licensed User
Longtime User
It works fine for me. I am attaching an example.
I guess you are getting the parameters wrong, instead of putting the branch ID you are perhaps entering the branch name



Scan the whole tree:
ScanTree("","")
ScanTrre Sub:
Private Sub ScanTree(IDB As String, space As String)
    Log(space & IDB)
    For Each IDLeaf As String In B4XTree1.ListOfIDLeafs(IDB)
        Log(space & " " & IDLeaf)
    Next
    For Each IDBranche As String In B4XTree1.ListOfIDBraches(IDB)
        ScanTree(IDBranche,space & " ")
    Next
End Sub
 

Attachments

  • Sample2.zip
    2.6 KB · Views: 201
Last edited:

micro

Well-Known Member
Licensed User
Longtime User
I guess you are getting the parameters wrong, instead of putting the branch ID you are perhaps entering the branch name
in fact I did so
menusd.ListOfIDLeafs(menusd.GetBranchName(ID)).Size
I was fooled by the word GetBranchName
with menusd.ListOfIDLeafs(ID) work fine
Thanks
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.20
  • GetLeafBadgeActive (IDLeaf As String) As Boolean
    Returns if the leaf has the active badge
  • GetLeafBadgeText (IDLeaf As String) As String
    Returns the badge text
 

Theera

Well-Known Member
Licensed User
Longtime User
Update 0.20
  • GetLeafBadgeActive (IDLeaf As String) As Boolean
    Returns if the leaf has the active badge
  • GetLeafBadgeText (IDLeaf As String) As String
    Returns the badge text
Is there example for study,sir? I'm rather stupid in coding and English,if I see example will make me understand how to use.
 

Cableguy

Expert
Licensed User
Longtime User
Is there example for study,sir? I'm rather stupid in coding and English,if I see example will make me understand how to use.
I can imagine something like...

B4X:
Sub B4XTree1_Click (IDLeaf As String, LeafName As String)
If GetLeafBadgeActive (IDLeaf) = True Then 'Leaf has a Badge
'Do something
Else 'Leaf has no badge
'Do something else
End If
End Sub
 

Star-Dust

Expert
Licensed User
Longtime User
Update rel. 0.21
  • Added AddLeafwithSymbol method. Now you can insert a Symbol with FontAwesone or FontMaterial in the branch

B4X:
    B4XTree1.AddLeafwithSymbol("Leaf B Symbol","Symbol","LBF","B1",Chr(0xF0F9),xui.CreateFontAwesome(14))

 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Update 0.22
  • Improved tree JSON production (method TreeToJson )

After obtaining the JSON (perhaps stored) you can transform it into MAP and populate the tree
B4X:
Dim Tm As Map = B4XTree1.TreeToJson.As(JSON).ToMap
B4XTree1.Clear
ScanMap(Tm,"")

Private Sub ScanMap(M As Map,IDParent As String)
    For Each K As String In M.Keys
        Log(K)
        Dim SubM As Map = M.Get(K)
        Log(SubM)
        If SubM.ContainsKey("Leaf")=False Then
            B4XTree1.AddLeaf(SubM.Get("Name"),SubM.Get("Info"),SubM.Get("ID"),IDParent)
        Else
            B4XTree1.AddBranch(K,SubM.Get("ID"),IDParent,SubM.Get("Symbol"),SubM.Get("Color"))
            ScanMap(SubM.Get("Leaf"),SubM.Get("ID"))
        End If
    Next
End Sub
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Update 0.25

  • Added InfotextSize field
  • Added Note field (to the right of the info)
  • Added AddLeaf3 and AddLeaf3OnTop methods


B4X:
B4XTree1.AddLeaf3("Leaf Sub 4","Info 4","Note 4", xui.CreateDefaultFont(12),xui.Color_Red, "LS4","S1",Chr(0xF270),xui.CreateFontAwesome(12))
B4XTree1.AddLeaf3OnTop("Leaf Sub 5","Info 5","Note 5",  xui.CreateDefaultFont(12),xui.Color_Red, "LS5","S1",Chr(0xF270),xui.CreateFontAwesome(12) )
 

CR95

Active Member
Licensed User
Hello SD,
This is a "beautiful" library.
I have some issues with the "click on leaf" -> need sometimes many pushs before to be fired in the program (may be because my list is long)
This is why I would like to inform the user afer a click -> is it possible to change ONLY the concerned leaf (by bolding or coloring the text for example) ?
I tried "B4XTree1.LeafTextColor" but it changes ALL the leafs.

Another point concerning the text in the leaves : the part of the characters under the line are "truncated" : for example "p" or "g".
May be you could change the vertical position in a future update ?

Thanks
 

Star-Dust

Expert
Licensed User
Longtime User
Hi, I'll try to look into the questions you raised
 

Star-Dust

Expert
Licensed User
Longtime User
Update rel 0.26
Increased height of elements, Highlighting of the clicked element​
 

CR95

Active Member
Licensed User
Thanks SD
I am travelling without PC and I cannot test your upgrades for the moment.
But I saw your small video and it seems that this does not correspond to what I suggested.
My demand was to change the color of the clicked leaf and to KEEP it colored (similar to a clicked button).
This will permit to the user to see/know what was his last demand among a long list of branches and leafs.

For the troncated text issue, did you try to center the vertical aligment ?
 

Star-Dust

Expert
Licensed User
Longtime User
But I saw your small video and it seems that this does not correspond to what I suggested.
My demand was to change the color of the clicked leaf and to KEEP it colored (similar to a clicked button).
I'm sorry that my change does not match your suggested request.
Unfortunately the suggested request does not correspond to the very meaning of the TreeListView. It would become a TreeCheckList, in the initial design it has the objective of being able to have lists grouped by branches and like all the lists being able to click on an item.

This will permit to the user to see/know what was his last demand among a long list of branches and leafs.

For the troncated text issue, did you try to center the vertical aligment ?
The entries are always centered, if you cut off a letter perhaps you have selected a font that is too large. In the examples this does not happen. In the last change I increased the height to allow the use of a larger font
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…