Page 1 of 1

What is wrong with this code?

Posted: Wed Nov 26, 2014 4:59 pm
by silvercover
Why does specified node get expanded but not selected?

Code: Select all

  If OpenWindow(0, 0, 0, 355, 180, "TreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    TreeGadget(0, 10, 10, 160, 160)                                         ; TreeGadget standard
    TreeGadget(1, 180, 10, 160, 160, #PB_Tree_CheckBoxes | #PB_Tree_NoLines)  ; TreeGadget with Checkboxes + NoLines
    For ID = 0 To 1
      For a = 0 To 10
        AddGadgetItem (ID, -1, "Normal Item "+Str(a), 0, 0) ; if you want to add an image, use
        AddGadgetItem (ID, -1, "Node "+Str(a), 0, 0)        ; ImageID(x) as 4th parameter
        AddGadgetItem(ID, -1, "Sub-Item 1", 0, 1)    ; These are on the 1st sublevel
        AddGadgetItem(ID, -1, "Sub-Item 2", 0, 1)
        AddGadgetItem(ID, -1, "Sub-Item 3", 0, 1)
        AddGadgetItem(ID, -1, "Sub-Item 4", 0, 1)
        AddGadgetItem (ID, -1, "File "+Str(a), 0, 0) ; sublevel 0 again
      Next
    Next
    SetGadgetItemState(0, 1, #PB_Tree_Expanded | #PB_Tree_Selected) ; The 2nd item is selected and expanded.
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf

Re: What is wrong with this code?

Posted: Wed Nov 26, 2014 5:12 pm
by RASHAD
Hi

Code: Select all

 If OpenWindow(0, 0, 0, 355, 180, "TreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    TreeGadget(0, 10, 10, 160, 160)                                         ; TreeGadget standard
    TreeGadget(1, 180, 10, 160, 160, #PB_Tree_CheckBoxes | #PB_Tree_NoLines)  ; TreeGadget with Checkboxes + NoLines
    For ID = 0 To 1
      For a = 0 To 10
        AddGadgetItem (ID, -1, "Normal Item "+Str(a), 0, 0) ; if you want to add an image, use
        AddGadgetItem (ID, -1, "Node "+Str(a), 0, 0)        ; ImageID(x) as 4th parameter
        AddGadgetItem(ID, -1, "Sub-Item 1", 0, 1)    ; These are on the 1st sublevel
        AddGadgetItem(ID, -1, "Sub-Item 2", 0, 1)
        AddGadgetItem(ID, -1, "Sub-Item 3", 0, 1)
        AddGadgetItem(ID, -1, "Sub-Item 4", 0, 1)
        AddGadgetItem (ID, -1, "File "+Str(a), 0, 0) ; sublevel 0 again
      Next
    Next
    SetActiveGadget(0)    ;Too be noticed
    SetGadgetItemState(0, 1, #PB_Tree_Expanded)
    SetGadgetState(0,1)
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf

Re: What is wrong with this code?

Posted: Wed Nov 26, 2014 5:18 pm
by silvercover
Thanks RASHAD.

I've copied that code from PB manual!
I think I'm getting old...

Re: What is wrong with this code?

Posted: Wed Nov 26, 2014 5:34 pm
by RASHAD
With your Silver Cover I do not think so :mrgreen: