[newbie] Explorer Tree Gadget problem

Just starting out? Need help? Post your questions and find answers here.
abarkley
User
User
Posts: 10
Joined: Sun Jun 07, 2009 7:44 pm
Location: London, UK

[newbie] Explorer Tree Gadget problem

Post by abarkley »

A real PB beginner here - been going about 2 weeks.

I want to show a directory (and contents) and get the user to select a (image) file which then gets loaded and worked on. Hard, huh?

What's wrong with this code:

If OpenWindow(0, 0, 0, 230, 220, "File example...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
ExplorerTreeGadget(0, 10, 10, 280, 280, "C:\Documents And Settings\Alastair\My Documents\My Pictures\project\*.*")
EndIf

Repeat
Event = WaitWindowEvent()

Select Event

Case #PB_Event_Gadget
Select EventGadget()
Case 1
Select EventType()
Case #PB_EventType_LeftClick : Debug "Click with left mouse button"
Case #PB_EventType_RightClick : Debug "Click with right mouse button"
Case #PB_EventType_LeftDoubleClick : Debug "Double-click with left mouse button"
Case #PB_EventType_RightDoubleClick : Debug "Double-click with right mouse button"
EndSelect
EndSelect

EndSelect


Until Event = #PB_Event_CloseWindow
EndIf


This seems to work for other gadget types but not with this one. What I'm expecting is that clicking on a file opens the Debug window....no it doesn't.

The rest of the code will be to get the actual file name and then use it for loading. How will that work?

I guess I may not have understood properly how this gadget really works.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Change 'Case 1' to 'Case 0'. :wink:
I may look like a mule, but I'm not a complete ass.
abarkley
User
User
Posts: 10
Joined: Sun Jun 07, 2009 7:44 pm
Location: London, UK

Post by abarkley »

Thanks. I knocked together the code from a couple of examples - I guess I'll see the error next time.

Please can you advise on the second problem: once I've been through the file tree and double clicked on the file that I want, how do I get the filename$?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Code: Select all

If OpenWindow(0, 0, 0, 230, 220, "File example...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
  If CreateGadgetList(WindowID(0)) 
    ExplorerTreeGadget(0, 10, 10, 280, 280, "C:\Documents And Settings\Alastair\My Documents\My Pictures\project\*.*") 
  EndIf 

  Repeat 
    Event = WaitWindowEvent() 
    Select Event 
      Case #PB_Event_Gadget 
        Select EventGadget() 
          Case 0 
            Select EventType() 
              Case #PB_EventType_LeftDoubleClick
                Select GetGadgetState(0)
                  Case #PB_Explorer_File 
                    Debug "Double-clicked file : " + GetGadgetText(0)
                  Case #PB_Explorer_Directory
                    Debug "Double-clicked folder : " + GetGadgetText(0)
                EndSelect
            EndSelect 
        EndSelect 
    EndSelect 
  Until Event = #PB_Event_CloseWindow 
EndIf 
I may look like a mule, but I'm not a complete ass.
abarkley
User
User
Posts: 10
Joined: Sun Jun 07, 2009 7:44 pm
Location: London, UK

Post by abarkley »

Thanks.

Exactly what I was trying unsuccessfully to do.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

You're welcome.
I may look like a mule, but I'm not a complete ass.
Post Reply