Treeview: Problem with expanding the items

BlitzMax Forums/MaxGUI Module/Treeview: Problem with expanding the items

mikelandzelo(Posted 2007) [#1]
Hey there,
I'm having some problems with my TreeView. It works, but there is no "+" symbol in front of the folder-items. They appear only if I double-click the items.

And that's not really nice, lol
any ideas?

here's my code:
Global TreeView:TGadget=CreateTreeView(ClientWidth(MainWindow)-210,35,200,360,MainWindow) 
Global TreeViewIconStrip:TIconStrip=LoadIconStrip("images/treeicons.png") 
SetGadgetIconStrip(TreeView, TreeViewIconStrip)
showTreeView(".",TreeView)



Select EventID()
	Case EVENT_GADGETACTION
		Select EventSource()
			Case TreeView
				Local Node:TGadget = SelectedTreeViewNode(TreeView)
				Local s:String=String(Node.Context)
				If s>""
					showTreeView(s,Node)
					Node.context=""
				EndIf
				ExpandTreeViewNode(node)
		End Select
End Select



Function showTreeView:Int(Dir:String, Parent:TGadget)
	Local Folder:Int=ReadDir(Dir)
	Local File:String
	Local FullPath:String
	
	Repeat
		File=NextFile(Folder)
		If File<>"." And File<>".." And File<>Null
			FullPath = RealPath(Dir+"/"+File)
			If FileType(FullPath)=FILETYPE_DIR Then
				Local handle:TGadget=AddTreeViewNode(File,Parent,0)
				handle.context=FullPath
			Else
				AddTreeViewNode(File,Parent,1)
			EndIf
		EndIf
	Until File=Null
EndFunction



thanks in advance!
mike


Gabriel(Posted 2007) [#2]
Yup, I reported this. I think Skidracer had a fix or a workaround to suggest, but I can't remember what it was now. I'll see if I can find it, and I'll edit this reply if I can.

Off the top of my head, I'm thinking he probably suggested expanding and contracting the node, but that I seem to recall that this didn't entirely suit my purposes at the time. But I think he had another suggestion, so hopefully I can find it.


mikelandzelo(Posted 2007) [#3]
ah, so it is actually a "bug"?
anyway, thanks man. Waiting for your answer :)


mikelandzelo(Posted 2007) [#4]
I've messed around with some functions and I tried it also with
RedrawGadget(TreeView)


But this works only, if I add new items to the TreeView manually (via my self-programmed interface). If I create the tree structure with the showTreeView()-function it will NOT work, weird...
And thats bad, if I want to load the tree from a save file.

Maybe someone can help me?

---

Another problem:
How can I remove a single item from the tree? I tried it with:
RemoveGadgetItem(TreeView,SelectedTreeViewNode(TreeView))


But it gives me an error: I need to declare an Integer (2nd argument) and I do have a TGadget. So how do I get the Int-value of the selected item (SelectedTreeViewNode)?


THX in advance


mikelandzelo(Posted 2007) [#5]
nobody knows?
I'd love to continue the work on my program. Any help would be appreciated.


LAB[au](Posted 2007) [#6]
For removing, Isn't it FreeTreeViewNode( node:TGadget )


mikelandzelo(Posted 2007) [#7]
Oh yeah. Wonderful, that helped!
Thanks man!

@Gabriel:
I hope you'll have some new infos on the expanding problem soon :-)


Gabriel(Posted 2007) [#8]
Sorry man, I completely forgot.

The thread I was referring to is this one.

http://www.blitzbasic.com/Community/posts.php?topic=63874

It requires a recompile of MaxGUI, though, which I can't personally do, so I can't tell you if it works or not. I'd really like to see it fixed for all though, as it's a real pain in the butt in my own project.