FreeGadget and recreate it

Just starting out? Need help? Post your questions and find answers here.
Netzvamp
New User
New User
Posts: 8
Joined: Sun Jun 24, 2012 6:25 pm

FreeGadget and recreate it

Post by Netzvamp »

Hi,
i have a problem with the FreeGadget() procedure. If i free a gadget i can't recreate it. Is that a bug or intended?

Code: Select all

OpenWindow(1, 0,0, 1000, 1000, "Title")

ScrollAreaGadget(1, 15, 60, 500, 500, 760, 360, 1, #PB_ScrollArea_Raised)
FreeGadget(1)
ScrollAreaGadget(1, 15, 60, 500, 500, 760, 360, 1, #PB_ScrollArea_Raised)
Debug IsGadget(1) ; Is 0, so the created gadget isn't there

Repeat
  event = WaitWindowEvent(1)
  
Until event = #PB_Event_CloseWindow
EDIT: With Buttongadget it works, so is it a bug with scrollareagadget?
EDIT2: Same happens with the containergadget
Netzvamp
New User
New User
Posts: 8
Joined: Sun Jun 24, 2012 6:25 pm

Re: FreeGadget and recreate it

Post by Netzvamp »

Some minutes later i answered my question by myself ;)

For history and other people 8)

It's about the Gadgetlists. You have to close the Gadgetlist before you free the gadget.

That code works:

Code: Select all

OpenWindow(1, 0,0, 1000, 1000, "Title")

Procedure test()
  ContainerGadget(1, 15, 60, 770, 370, #PB_Container_Raised)
  CloseGadgetList()
  FreeGadget(1)
  ContainerGadget(1, 15, 60, 770, 370, #PB_Container_Raised)
  Debug IsGadget(1)
  CloseGadgetList()
EndProcedure

test()
test()
test()

Repeat
  event = WaitWindowEvent(1)
  
Until event = #PB_Event_CloseWindow
Post Reply