I guess i didnt make myself clear. Here is the updated code with line that causes problem highlighted!
SuperStrict
Local MyWindow:TGadget=CreateWindow("TreeView Example", 40,40,400,400)
Global MyTreeView:TGadget=CreateTreeView(5,0,200,330,MyWindow)
DebugLog MyTreeView.tostring()
EnumFiles(BlitzMaxPath(),MyTreeView)
'--------------------------------------------------------
Repeat
'--------------------------------------------------------
WaitEvent()
Select EventID()
Case EVENT_WINDOWCLOSE
End
Case EVENT_GADGETACTION
DebugLog "event id = " + EventID() ' EVENT_GADGETACTION
DebugLog "event source = " + EventSource().tostring() ' MyTreeView
DebugLog "event data = " + EventData() ' ?
DebugLog "event extra = " + EventExtra().tostring() ' Node
' DebugLog "event text = " + EventText() ' ?
' DebugLog "event mods = " + EventMods() ' ?
Local Node:TGadget = SelectedTreeViewNode(MyTreeView)
Local s:String=String(Node.Context)
If s>""
EnumFiles(s,node)
node.context=""
EndIf
ExpandTreeViewNode(node)
End Select
Forever
End
'--------------------------------------------------------
Function EnumFiles:Int(Dir:String, Parent:TGadget)
'--------------------------------------------------------
Local Folder:Int=ReadDir(Dir)
Local File:String
Local FullPath:String
Repeat
File=NextFile(Folder)
If File=".." Or File="." Or File=Null Then
'Do Nothing
Else
fullPath = RealPath(Dir+"/"+file)
If FileType(FullPath)=FILETYPE_DIR Then
Local handle:TGadget=AddTreeViewNode(file,Parent,-1)
'********************************************************
handle.context=FullPath
'********************************************************
Else
AddTreeViewNode(file,Parent,-1)
EndIf
EndIf
Until File=Null
End Function
|