Hi All.
This is most likely a really stupid error on my part but I've had a look through the forum and haven't found out what I should do.
Basically, I have a treegadget with a few items added.  These are URLs that I intend to click on and open the relevant page with runprogram.
This all works fine if IE isn't already opened.  If it is already opened it opens 2 or 3 (or 4 or 5!) identical tabs rather than only one.
What I need to do in my code is ensure that my runprogram statement is fired only once but I don't know how to 'deselect' the treeitem I've just clicked on so that it doesn't get fired again next time through the event loop.
Hope some of this makes sense.
Thanks in advance.
M.
			
			
													TreeGadget problem[resolved]
TreeGadget problem[resolved]
					Last edited by Mikro on Fri May 18, 2007 7:31 pm, edited 1 time in total.
									
			
									
						Thanks guys.
I didn't want to list my beginner code! 
 
Anyway, here is a snippet of the code in question. As I say, it's probably something silly I've done.
I don't know how to 'reset' the treegadget. I mean, after clicking on an entry once, the browser will open. But if I click anywhere on the treegadget again (to expand it say, it will still fire the runprogram line as the previous selection is still active). I'm just not sure of how to differentiate between me ckicking on a node or an actual item. NB. This is in addition to the browser sometimes firing twice on each click.
Thanks for any help you have.  It's not for a particular project or anything.  I was just playing around in a bit of freetime I had, never get a good chance to use my PB! 
			
			
									
									
						I didn't want to list my beginner code!
 
 Anyway, here is a snippet of the code in question. As I say, it's probably something silly I've done.
I don't know how to 'reset' the treegadget. I mean, after clicking on an entry once, the browser will open. But if I click anywhere on the treegadget again (to expand it say, it will still fire the runprogram line as the previous selection is still active). I'm just not sure of how to differentiate between me ckicking on a node or an actual item. NB. This is in addition to the browser sometimes firing twice on each click.
Code: Select all
For x=0 To 9
  AddGadgetItem(2,-1,"Test" + Str(x),0,0)
  AddGadgetItem(2,-1,"www.google.com",0,1)
  AddGadgetItem(2,-1,"www.bbc.co.uk",0,1)
Next x
Repeat
  MainEvent = WaitWindowEvent()
  
  Select MainEvent
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 2  ;this is the treegadget
          item =GetGadgetState(2)
          If Left(GetGadgetItemText(2,item,0),3)="www"
            RunProgram(GetGadgetItemText(2,item,0))
            SetGadgetItemState(2,item,#PB_Tree_Checked) ;this is probably wrong, trying to reset the gadget
          EndIf
          
      EndSelect
   EndSelect 
Until MainEvent = #PB_Event_CloseWindow

Check for the event type:
			
			
									
									
						Code: Select all
OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
TreeGadget(2, 10, 10, 400, 300)
For x=0 To 9 
  AddGadgetItem(2,-1,"Test" + Str(x),0,0) 
  AddGadgetItem(2,-1,"www.google.com",0,1) 
  AddGadgetItem(2,-1,"www.bbc.co.uk",0,1) 
Next x 
Repeat 
  MainEvent = WaitWindowEvent() 
  Select MainEvent 
    Case #PB_Event_Gadget 
      Select EventGadget() 
        Case 2
          If EventType() = #PB_EventType_LeftDoubleClick
            item = GetGadgetState(2)
            If Left(GetGadgetItemText(2,item,0),3)="www"
              Debug (GetGadgetItemText(2,item,0))
            EndIf
          EndIf
      EndSelect 
   EndSelect 
Until MainEvent = #PB_Event_CloseWindow

