treeview problem...

BlitzMax Forums/MaxGUI Module/treeview problem...

danielos(Posted 2008) [#1]
Hi!

Working around with the TreeView-Gadget, I came to a problem I am not able to solve:
In a Treeview-Gadget a unknown (!) number of nodes is created. Now there shall be added a textarea to each of these nodes that appears if the node is selected.

How is it possible to get this ?

Thanks!

Cheers,
Daniel


jsp(Posted 2008) [#2]
Every node of a treeview is a TGadget, thus you can make usage of the SetGadgetExtra()/GadgetExtra() functions, which can attach an object to the TGadget (your nodes).!

Create only one! Textarea.

Attach your “textarea text” via SetGadgetExtra to the node you add to the treeview.

When you select a node later in the treeview, read the “textarea text” via GadgetExtra and present it in the real Textarea. Just don't forget to cast the object retrieved from the node, depending on what you have stored.
For text: MyString:String = String(GadgetExtra(TreeviewNode))


danielos(Posted 2008) [#3]
Thanks, but the "SetGadgetExtra" comand was not found ?!

I have to admit that I use Listboxes with the treeviews, not textareas... this was just not the point I was wondering about, you know...


jsp(Posted 2008) [#4]
Your MaxGui version is too old then! You should update to the latest release.

If you can't update, you can use the context field of the TGadget.
TGadget(Node).context=”Textarea text”
or
MyString:String = String(TGadget(Node).context)


Listboxes?
Then store a Tlist or array into the context, which loads the Listbox contents.


danielos(Posted 2008) [#5]
Ah... my mistake ^^
Thanks again!


danielos(Posted 2008) [#6]
So here I come to the problem:

Import maxgui.drivers

Global mainwindow:TGadget=createwindow("window",200,200,500,500,desktop())
Global BooklistTree:TGadget=CreateTreeView(0,0,200,300,mainwindow)
AddTreeViewNode("test",BooklistTree)
Local roottree:TGadget = AddTreeViewNode("Root", TreeViewRoot(BooklistTree),1)
Local count:Int
Local listbox:TGadget[200]
Local treebooklist:TGadget[200]
Repeat
	treebooklist[count]=AddTreeViewNode(String(count),roottree,0)
	listbox[count]=CreateListbox(200, 0, 300, 400, mainwindow)
		hidegadget listbox[count]
		treebooklist[count].context=listbox[count]
	count=count+1
Until count=10

'....

Repeat
        Local W_Event:Int=WaitEvent()
	Select W_Event
              Case EVENT_GADGETSELECT
			Local E_Source:Object=EventSource()
			Select E_Source
				Case treebooklist
					Local Node:TGadget= SelectedTreeViewNode(booklisttree)
	       			' So what now ?	
					
	                End Select
             Case EVENT_WINDOWCLOSE End
       End Select
Forever



jsp(Posted 2008) [#7]
To be honest, you should change the concept. I don't think it's a good idea to create 200 Listboxes...
Nevertheless see below how your code works:






danielos(Posted 2008) [#8]
Thanks jsp, and of course you are right, it is not a good idea to create 200 Listboxes...
just to explain the problem:
There will be several files in a folder, and for each of these files, there should be a listbox (or at least a listbox content) that contains several data of the file...
The exact number of the files is NOT KNOWN, which makes the problem not easier :-p
my idea (bad ^^ ) was to create 200 listboxes, because it seems not likely that there are more files in the folder...

Any thoughts ?

Greetz,
Daniel


Brucey(Posted 2008) [#9]
Can't you have one listbox which you re-populate based on the file you are inspecting?


danielos(Posted 2008) [#10]
Should be possible, was just not my first thought, because it seemed too nasty to delete/add list items all the time (but now I guess its way easier than my idea :-) ) I will try this out today...
Thanks Brucey!