Page 1 of 1

4.31 ContainerGadget trouble adding OptionGadgets

Posted: Tue Jun 16, 2009 12:43 pm
by Marlin

Code: Select all

If OpenWindow(0, 0, 0, 320, 350, "ContainerGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ContainerGadget(0, 5, 5, 310, 150, #PB_Container_BorderLess)
    OptionGadget(0, 10, 20, 100, 20, "Option 1")
    OptionGadget(1, 10, 45, 100, 20, "Option 2")
    OptionGadget(2, 10, 70, 100, 20, "Option 3")
  CloseGadgetList()
  ContainerGadget(1, 5, 160, 310, 150, #PB_Container_BorderLess)
    OptionGadget(3, 10, 20, 100, 20, "Option A")
    OptionGadget(4, 10, 45, 100, 20, "Option B")
    OptionGadget(5, 10, 70, 100, 20, "Option C")
  CloseGadgetList()
  
  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
With the above code I get quite a lot of gtk related compiler warnings
and the first 3 "OptionGadget" lines get yellow excamation marks.

When the window appears only the 3 OptionGadgets, that did not get the warnings (A,B,C) are visible.

I would post the compiler output here, but I don't know how to copy it yet.

This problem only seems to affect the first ContainerGadget;
when I tried to add a third ContainerGadget, it seemed all right
just like the second one.

Posted: Tue Jun 16, 2009 12:51 pm
by freak
Your first OptionGadget has the same ID (0) as the ContainerGadget where you try to create it in. So the ContainerGadget gets destroyed while the OptionGadget is created. This is where the problems come from.

Posted: Tue Jun 16, 2009 12:59 pm
by Marlin
:oops:

Your right.

Thank you.