Treeviewnode

BlitzMax Forums/MaxGUI Module/Treeviewnode

MacSven(Posted 2009) [#1]
The treeview handling is very bad. I have something like that:



It show me now a directory only with html files.
Now how can i make a text based list that shows me the content of all kids in the root tree?


SebHoll(Posted 2009) [#2]
Just iterate through node.kids. I coded this function for you, to give you an example of how you would do it:

Function TreeViewNodeToTextList:String( treeview:TGadget, node:TGadget, strLinePrefix:String = "" )
	
	' Decorative function-specific fluff
	Local tmpString:String, tmpPrefix:String = ""
	If node <> TreeViewRoot(treeview) Then
		tmpString = strLinePrefix
		If Not node.kids.IsEmpty() Then
			tmpPrefix = "| "
			tmpString:+"- "
		Else
			tmpString:+"| "
		EndIf
		tmpString:+ GadgetText(node) + "~n"
	EndIf
	
	' Main iteration and recursion
	For Local tmpChild:TGadget = EachIn node.kids
		tmpString:+TreeViewNodeToTextList( treeview, tmpChild, tmpPrefix+strLinePrefix )
	Next
	
	Return tmpString
	
EndFunction
The function outputs the following when used on the treeview root in the CreateTreeView() example:

- Help
| | Topic 1
| | Topic 2
| | Topic 3
- Projects
| - Project 1
| | | Sub Project
| | Project 2
| | Project 3

Hope this helps!


MacSven(Posted 2009) [#3]
Hi Seb,

Then i am using a your code it shows me nothing. I have inserted
the root of the tree and the node, is that right?

Is it possible to list all nodes than i am using the counttreeviewnode() function?

Is the node list a tlist?

Sven


SebHoll(Posted 2009) [#4]
You need to pass to it the treeview gadget itself, and then the node you whose children you want to print.
TreeViewNodeToTextList( treeview, TreeViewRoot(treeview) )
And here is the source code of the example (look for my 'SEE HERE comment):




MacSven(Posted 2009) [#5]
Hi Seb,

I have used you sample is it possible that the code does not work under MacOS X10.5.7 with BlitzMax1.30?

Sven


SebHoll(Posted 2009) [#6]
I have used you sample is it possible that the code does not work under MacOS X10.5.7 with BlitzMax1.30

Yep - this was only fixed in MaxGUI.CocoaMaxGUI v1.43. Which version of CocoaMaxGUI do you have?

To find out, open up BlitzMax/mod/maxgui.mod/cocoamaxgui.mod/cocoamaxgui.bmx and have a look at the ModuleInfo block. If your version number is less than 1.43, you might want to consider upgrading to MaxGUI 1.32 or maybe even MaxGUI v1.33 RC1.


MacSven(Posted 2009) [#7]
Hy Seb

I have updated the MaxGUI to MaxGUI 1.32 and it works now.

Thanx for the Info's