In order to keep your window responsive you have to implement
an event loop. In your example you don't look for events at all. I
have modified your example to use a timer which counts up your
x value every second (1000 ms). In that way your window and
gadgets allways stay responsive. Another point is that in order
to display text in a TextGadget you don't have to recreate that
gadget but instead use SetGadgetText() to update the content
of your TextGadget:
Code:
OpenWindow(0, 0, 0, 200, 200, "TestBox", #PB_Window_SystemMenu)
TextGadget(0, 10, 100, 180, 20, "", #PB_Text_Center)
SetGadgetText(0, "x=0")
AddWindowTimer(0, 0, 1000)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
RemoveWindowTimer(0, 0)
Break
Case #PB_Event_Timer
x + 1
SetGadgetText(0, "x=" + Str(x))
EndSelect
ForEver